When I receive a message on Facebook I get a push notification on a lock screen (iOS). Then I read this message on desktop. Right after that this push notification disappear
This is a new feature on iOS 7 called Silent Push Notification, its a multitasking feature.
What you will need:
1 - Register for Remote Notifications in didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeNewsstandContentAvailability|
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
}
2 - Implement following method in ApplicationDelegate:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
handler(UIBackgroundFetchResultNewData);
// Possibl Results:
// typedef enum {
// UIBackgroundFetchResultNewData, //Download success with new data
// UIBackgroundFetchResultNoData, //No data to download
// UIBackgroundFetchResultFailed //Downlod Failed
// } UIBackgroundFetchResult;
}
3 - Set UIBackgroundModes inside Application info.plist:
> UIBackgroundModes
> remote-notification