Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for handling notification without requiring user interaction #27

Open
eladmoshe opened this issue Apr 27, 2015 · 2 comments

Comments

@eladmoshe
Copy link

A great feature to consider adding is handler for silent push notifications, which allows the application to respond to push notifications while running in the background, for example for fetching new data from the server, without requiring user interaction. The following code will print a line to the log on iOS when a notification is received:

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary*)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
       NSLog(@"received push notification");
       [completionHandler userInfo];
}

I still haven't looked into Android implementation.
Currently the plugin only allows to respond to notifications once the user clicked a notification.

@AntonDobrev
Copy link

Hi Elad,

Thank you for you input.

Indeed, this new method was added in iOS 7 (here is a link to the API reference) but somehow was overlooked in the plugin. For native apps it works seamlessly, however, as far as I am concerned it depends if the OS guarantees the app will be awaken. We will consider implementing this if there is an appropriate Cordova way to plug into the background of the app when to supply a callback to this method via Cordova.

I need to mention that there is another way to ensure the app will be awaken in the background to consume pushed content via the 'content-available' key in the payload of the notification. You need to set it to 1 in the payload to invoke a handler that will download an available content. Yet we will need to check for a suitable Cordova implementation.

Though both approaches are slightly different, it feels appropriate to mention them and implement them in the plugin.

Let me know if you have further questions or suggestions.

Best,
Anton

@dortzur
Copy link

dortzur commented May 10, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants