Reputation: 270
I have a problem with detecting a push notification from APNS.
If there is a push notification from APNS when the app is not running or in background,
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
is not work.
And when I'm back to the foreground without selecting a push notification message from notification centre, it is not work.
How can I solve this problem?
I'm testing the app in iOS 6.13 and iOS 7.0.4.
Thanks for your help. :)
Upvotes: 2
Views: 5630
Reputation: 2344
From Apple documentation:
Implement this method if your app supports the remote-notification background mode.
Which mean the method you are using focuses on the background task. And only available after iOS 7.0.
I recommend you use application:didReceiveRemoteNotification:
.
From Apple documentation:
If the app is running and receives a remote notification, the app calls this method to process the notification.
Upvotes: 1
Reputation: 1320
Actually,the first receiver of notifications is system,not your app.
If your app isn't in foreground, app's application:didReceiveRemoteNotification:fetchCompletionHandler
will never be called until you tap the notification to make your app becomes to the foreground again.
When a push notification arrives and the user clicks 'cancel
', your app has no way to read that push notification again
. You have to implement a separate functionality (most probably on server-side
) to fetch a list of notifications sent to this device.
Upvotes: 2