In my application I have two types of push notifications: remote silent notifications with content-available = 1
flag and usual push notifications with body
, badge
and other stuff.
I also define two delegate methods didReceiveRemoteNotification:fetchCompletionHandler
and usual didReceiveRemoteNotification
.
But when a push-notification without content-available
flag arrives didReceiveRemoteNotification:fetchCompletionHandler
is called, instead of didReceiveRemoteNotification
.
How to fix this?
Why can't I have two delegate methods for background and usual pushes?
iOS 7 only calls the new one, this is how I handled it in my app:
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Pass on
[self application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:nil];
}
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Check if in background
if ([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) {
// User opened the push notification
} else {
// User hasn't opened it, this was a silent update
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With