iOS Silent Push notifications

iOS Silent Push notifications is a great feature released in iOS7. When a silent push notification reaches device, user does not know anything about the notification. But your app gets the notification and app will be given some time to download new content and present it to the user.

Silent remote notifications can be useful for

  •     Episodic content—TV shows, podcasts
  •     Read these stories later
  •     Purchase syncing
  •     File syncing

What you need to for iOS Silent Push Notifications ?

1) App’s Info.plist should have UIBackgroundModes set to remote-notification


Silent Push Notifications in iOS

2) You need to implement following method in ApplicationDelegate

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


When a push notification arrives, the system calls this method before displaying the notification to the user.
Use this method to download the data related to the push notification and prepare to display it. When your method is done, call the block in the handler parameter.

typedef enum {
	UIBackgroundFetchResultNewData, //Download success with new data
   	UIBackgroundFetchResultNoData,  //No data to download
   	UIBackgroundFetchResultFailed   //Downlod Failed
   	} UIBackgroundFetchResult;


How it is different from application:didReceiveRemoteNotification:?
application:didReceiveRemoteNotification: method is called only when your app is running.
But application:didReceiveRemoteNotification:fetchCompletionHandler: is called regardless of app state.If app is suspended or not running, then the system wakes up or launches your app and puts it into the background running state before calling the method.
This method is intended for showing the updated content to the user.When this method is called, your app has up to 30 seconds of wall-clock time to perform the download operation and call the specified completion handler block. If the handler is not called in time, your app will be suspended.

3) Register for Remote Notifications in didFinishLaunchingWithOptions

// register for types of remote notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
                                            UIRemoteNotificationTypeBadge |
                                            UIRemoteNotificationTypeSound |

Push notification Payload Formats:

1). Remote Push Notifications
Remote Notifications in iOS7

Remote Push notification Payload:

aps {
content-available: 1
alert: {...}


2). Silent Push Notifications
iOS Silent Push Notifications

Silent Push Notification Payload :

content-available: 1