this sounds promising!
Silent notifications have been tested successfully. On iOS you have to activate this as a capability in the Background Modes section. It’s named “Remote notifications”.
Then I added an AppDelegate method
Something like this:
Jason, of course you know better than anyone else about the details. The following is just for all the guys not familiar with it so everybody can get a clue about what we’re talking about.
Using this concept I can use EVERY iOS feature within Omnis.
Generally we face two situations:
1. Actions initiated by iOS itself (like push notification)
In this case we simply need to define a module method and call it using the procedure described above.
2. Actions initiated by Omnis with some iOS follow up and results given back to Omnis.
Example: At some time in code I need the push token of the device so the server app can push a message to the device at any time. Therefore I’ve written a new device method
getPushToken that in return calls
jsWrapper.getPushTokenComplete. At app init I get the push token from iOS infrastructure and save it in an iOS variable for later use.
To be more generic it might be a good idea to initiate the push stuff from an Omnis method so it would be up to the developer if he uses push functionality or not. This might be important because the user could be annoyed if he gets the notification about allowing push notifications being sent the very first time of app use. If this is within a device call the omnis developer can decide whether to bring it up or not. Callback is done asynchronously as always using my jsWrapper module.
To give you some idea about the js code within Omnis I give you my module skeleton here:
The following must be placed within the $init method of your apps offline form
As you can see we’ve defined these methods here:
These methods call my Omnis delegate methods
Now it’s easy to use Omnis Code to handle the results of all this.
To give you a more concrete sample:
I want to use the fingerprint sensor within my app to make the app more secure.
First I need to test if touchid is available. If it’s not (iPhone 4), it doesn’t make sense to show a fingerprint icon in the app.
So I’ve written a command
touchidTest. The result is given in a call to
jsWrapper.touchidTestComplete which calls the omnis method
$touchidTestComplete(lVar). The parameter gives info whether the hardware is available or not.
If it’s available I can call device method
touchid which brings up the typical fingerprint message on the iPhone. Finally the result is given in method touchidComplete which call omnis method $touchidComplete(lVar) with result of id process.
The push notification is given in didReceiveRemoteNotification with some action and data information in its two parameters. This is useful to have some different action types like data update push, private message, breaking news etc. Data contains even more payload.