Post
by Mikey » Thu Jun 27, 2019 9:07 pm
One other thing to remember, because sooner or later this will bite you: On iOS, the pushID of the device WILL change periodically (and the user might also disable push notifications, so the pushID would be empty). It can happen when the device gets wiped, when there is a major OS update, when the user uninstalls/reinstalls your app, and I don't know when else. All I know is that it will change, and in the cases of some devices, multiple times in a fairly short period. At startup we therefore grab the push ID, compare it to the old push ID, and if it's changed we notify our server. If the user uninstalls and reinstalls your app, there's a good chance the app data got wiped, too, so just keep that in mind.
Starting with your P.S., I don't know the mechanics of it. It might be that LC can't do anything more than what it does (but obviously I don't know that).
When you launch the app, all you can do is check the badge. After that you have to decide what to do. What I would suggest is you have your app poll your server to see what's up.
Since Dropbox is quick, cheap, and easy to use with LC (and conceptually easy), what I suggest is this:
1) When your server decides it needs to notify a mobile, it can write a file to Dropbox. Alternatively, on the server you can have a DB that keeps track of the mobiles and knows what needs to be sent to the mobile.
2) Push. Don't expect the message to arrive, or for the payload to be of any use. Set the badge, though. Your server can, as part of tracking the mobile, know the last value of the badge, and increment it, if you like.
Then in the app,
1) When you start, check the badge. If the app is already running and it gets a notification, you'll get a payload, which you can use
2) Either prompt the user to poll the server, or do it automagically. If you are prompting the user, you can add a "sync" button for them. This is our preferred way to do things because we assume poor network connectivity and "I've got better things to do than wait for this thing to phone home". If your users are on a phone, then maybe the poor network connectivity might not be an issue. For wifi devices in a warehouse or off-site, their normal mode will be poor or no network.
3) When you want to hit the server, if you're using Dropbox, grab the file for the device and see what it says, or if you're hitting you own server, log in and see what you're supposed to do.
4) If you're going the Dropbox route, your app should remove or otherwise mark the file, and reset its badge to 0. If you're using your own server, your server can push an empty payload with a "0" badge when it is satisfied that the app has completed its tasks (you could also let the app do this, of course).