Updating Slack Home Tab In Mobile (views.publish) After view_submission From Modal - modal-dialog

What is the proper way to update the home tab on the Slack mobile app after a modal sends a view_submission event? FWIW, the home tab updates on the web UI but on mobile it does not and the person has to click away from the home tab and then back on it to update it.
Here is the flow I'm using:
Modal is opened and person submits form from modal.
Modal sends view_submission to my app.
My app sends {'response_action': 'clear'}.
My app posts home tab layout to views.publish.
I'm expecting the home tab layout to update. On the web UI it does update, but on the Slack mobile app it does not update. On the mobile app you have to tap to another section (eg Messages tab or another conversation) and then back to the home tab for the update to happen.

A work around (or maybe the correct way to do it depending on how you interpret Slack's documentation) is to return the acknowledgement response when you get the view_submission request from slack BEFORE you make a post request to view.publish.
Generally speaking, the simplest way to process the flow above is to take the view_submission data, figure out what updates need to be made, post the update via views.publish, and then return the acknowledgement response {'response_action': 'clear'} all in a single synchronous process. This works as expected on web, but not on mobile. Instead, however, if you break it into two steps and use a job queue or other asynchronous system to offload the processing of the view_submission data and posting the update via views.publish and immediately return the acknowledgement response then it works as expected on web and mobile. For performance reasons you'll just want to make sure that the view_submission data gets processed immediately after returning the acknowledgement response.

Related

Where to place alertbox in flutter?

I have a flutter app that uses flask as backend and when ever some data changes in the backend, I want to send an Alert Dialog to user. Although I know how to use Alert Box, I'm confused where the code for it should be placed as I'm using 3 screens and navigating then via PageView.
My use case is that I have a PIR sensor equipped onto a raspberry pi and when ever motion is detected, motion_status value turns to true and sends to flutter app via flask app.
I'm confused about where i need to place the Alert Dialog widget so that when ever movement happens, no matter what screen i'm in i should get alert box .
So when an update happen in the backend, you have couple different ways to get the app notified about the change just happened,
1- first you create a stream in the flutter app calling the server to check if any change happened, that stream reoccurs every few minutes or seconds, but that's not a good solution because there will be a lot of calls to the server and the info won't be instant.
2- use a web socket system
Best solution
3- use FCM Firebase cloud messaging system, whenever a change happened in the backend you write a code that calls Firebase account associated with your flutter app and your Firebase account will send a notification with data load to your app, when your app receives that real time notification you can then show to the user the alert dialog

Automated Actions - Mouse Clicks Based on Text Displayed

I am looking for a way to automate mouse clicks based on display text on screen.
The main function is the following:
- When bot detects "Hello!" on screen of Facebook Messenger, it clicks to open conversation. Then it reads the message (messages are always the same) and depending on the messages received it clicks on Saved Replies and sends the correct message.
For example:
Bot detects "hello!" it clicks and opens the conversation. Then bot reads "Amazing Offer 20% off" so it goes to Saved Replies and sends the correct message according to that offer.
*Saved replies is a canned message function that facebook for business messages offers as a function. So basically all I need is a bot that can automate clicks and detect text on screen. It will be run from a PC using Windows.
Any suggestions?
There are three options.
1) Use the Facebook API.
Facebook have spent time and effort to build a system in which developers can interact with their products. Here is a link: https://messengerplatform.fb.com
Options that might be against their policies and will get your account blocked (or worse):
2) Chrome Extension.
Through a Chrome extension, you have the ability to scan the DOM every few seconds and interact with the elements.
This needs to be maintained as Facebook might change element positions, ids or classes. https://developer.chrome.com/extensions/getstarted
3) PhantomJs.
This is a headless browser which you can run and interact with the DOM elements. This also needs to be maintained as the DOM may change at any time.
http://phantomjs.org/page-automation.html

How to handle multiple push notifications with user data arrived at different times?

My app is receiving APNs sent from server to Apple backend. Naturally a user may not open the app once a notification arrives to user's device. In meantime my server may push more notifications. They all contain some user data that is important when a notification is processed. So how to deal with it? iOS won't bundle and give me a batch, will it?
Here are ways how I am going to tackle it, none of which is simple.
Server keeps track of not seen data and upon arriving a new request always sends a batch of all new notifications, reflecting the count as badge count.
Client is opened by taping on notification popup. In this case it has all needed data in didReceiveRemoteNotification.
OR
Client ignores notification popup and opens app (possibly later) by tapping on app icon. In this case didReceiveRemoteNotification is not called and thus app has to fetch all needed data from server.
OR
Server never sends any user data and client always checks for new stuff every time it starts or fetches data in didReceiveRemoteNotification.
Anything else? Something simpler I am missing?
Number 4 is the right approach. There is no guarantee that any of your app code will run when an APN is received, except on iOS7. So when your app starts, it has to check with your servers for any new information that it should display.
It's simplest to code this to alway ask your servers for the latest information to display, rather than rely on the information in the APN. Use the information in the APN only to determine which new information to navigate to, so that the app displays whatever the user tapped on.
This has changed with iOS7, where you can use the remote-notification background mode to be launched whenever a push message arrives. See https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler:

Facebook notification system: Is it polling?

Notification when the user first login, not so hard, just require a database scan, I can deal with that. However, when a friend send a request or comment on profile X, a notification is sent, and almost immediately receive on the other end even when the user X not making any request. Is it polling? Does not feel like it, since the page never refresh itself. It must be something else? Anyone have any idea? maybe Web Push?
Facebook uses long-polling.
While you're on their page, they have a script continually issue requests to a particular URL. Instead of immediately responding, the server handling that URL first waits for a message to come in to its queue, and then sends that message out to the user. If a certain timeout is reached, the server responds without sending a message, and the client-side script makes another request to that URL.
To see this in action, open up Firebug's Net tab while on a Facebook page and wait for a couple minutes. You should see requests that last for a minute and then are followed up with a new request.
I believe they use AJAX/Javascript for that. It would allow the page to get information from the server and display it without reloading the page. You should be able to do this with an AJAX library like JQuery or something similar. As for whether or not Facebook itself does push or poll, I have no idea, but you can get a similar behavior by polling with AJAX.

Availability of Push notification service in this situation?

i'm working on a football application. the application connects to a webservice and gets the required data via soap request whenever a tab is opened. one of the tab shows live matches of the current day. when the live tab is opened, it refreshes the view by a timer and shows the status updates (goal scored, half time or full time). what i need to do is getting the status updates when the app is closed. the user will select max 2 competitions from settings of the app. then the status updates about these 2 competitions needed to be alerted. can i use push notification service to send soap requests and make alerts according to the response? or does it only allow getting response? or is there anyway that i can do it?
thanx in advance.
I'm not entirely clear what you are asking. The part where you write:
can i use push notification service to send soap
requests and make alerts according to the response?
or does it only allow getting response?
isn't really clear to me. What response are you talking about?
In any case.. push notification is what is says. It pushes a notification to the iPhone.
It does not:
activate your application in the background
allow for any action of your application without the user opening said application first
allow any kind of data to be gather from the phone
If you want the user's phone to talk to your server, the user will need to open your application. If that's what you're asking.