Question

I am working on a app, where I need to send a push notification to the app to start processing data as needed.

How do I send a push notification to the device so that instead of showing the alert message, the notification is forwarded to the app - whether the app is in the foreground or background..

I did implement the delegate method :

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

however this is called only when the app is in the foreground. When the app is in the background the notification shows up on the notification center.

Please advice.

Was it helpful?

Solution

To make this works you need to do few step:

  • set background mode remote-notification

  • implement application:didReceiveRemoteNotification:fetchCompletionHandler: method in app delegate

  • and make sure push notification payload contains key "content-available" : 1

related docs:

App States and Multitasking

Local and Push Notifications in Depth

OTHER TIPS

Is your application using a backend? An example would be Parse or another to store your data.

Parse, for example, allows you to add push notifications that can be customized and changed to get the most out of your application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top