user3431473 user3431473 - 1 year ago 77
Objective-C Question

How to consume iOS Push notification in the app only

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
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
. When the app is in the
shows up on the
notification center

Please advice.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download