-
Notifications
You must be signed in to change notification settings - Fork 378
Push notifications tutorial
This will only be a tutorial on implementing Push Notifications in Baker. For general information about Push Notifications, see:
- Apple Push Notification Services Tutorial: Part 1/2 by Ray Wenderlich
- Apple's own documentation About Local Notifications and Push Notifications and Newsstand FAQ - Delivering Your Content
You will need an APNS device token for any device you want to send a notification to. The token is generated on the device when a user agrees to receiving push notifications when first opening an app. Baker will send the token to your server using the APNS device token endpoint.
Baker applications natively support only Newsstand Content Availability notifications, the ones used to start the background download of a issue. The standard payload that you must send within your notification is a JSON object exactly like this:
{
"aps": {
"content-available": 1
}
}
This will cause a refresh of the shelf and the background download of the latest issue.
Baker applications also support the background download of a specific issue on the shelf. To specify which issue is the one that should be downloaded you could extend the notification payload like this:
{
"aps": {
"content-available": 1
},
"content-name": "a-study-in-scarlet"
}
This will cause a refresh of the shelf and the background download of the issue named "a-study-in-scarlet"
There are two things to remember while working with push notifications in Baker (or in any other application), which are already pointed out in the links posted above, but deserve a direct reminder here:
-
You can start only one background download every 24 hours. However, you can override this limit while testing, by enabling
NKDontThrottleNewsstandContentNotifications
inAppDelegate.m
, as in the following example:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NKDontThrottleNewsstandContentNotifications"];
...
- While you can extend the support to the other types of notification and/or customize your notification payload with other custom properties, you should keep the "aps" object reserved for Apple coded properties and add custom properties outside it.