I'm implementing newsstand features in an application and though the app receives the push notification it does not start in background mode.
If I tap the notification alert the the app starts and I can see "content-available":1 is present in the dictionary and also the issue is downloaded, but the app is not automatically launched.
I've added to the plist:
<key>UIBackgroundModes</key>
<array>
<string>newsstand-content</string>
</array>
and to didFinishLaunchingWithOptions:
[[NSUserDefaults standardUserDefaults]setBool: YES forKey:@"NKDontThrottleNewsstandContentNotifications"]; // for testing purposes
[[NSUserDefaults standardUserDefaults] synchronize];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeNewsstandContentAvailability )];
I also see that my app is not shown under Settings -> Store -> Automatic Downloads (and other magazines appears there).
Am I missing something? Is this supposed to work in sandbox environment?
Some clarifications
NSDictionary *payload = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(payload && [[payload objectForKey:kContentAvailablePush] caseInsensitiveCompare:@"1"] == NSOrderedSame) { NSLog(@"Launched due to NS notification"); }
You have to register for newsstand notification in order to appear in Settings and receive the "newsstand notifications". To register, add this to your
application:didFinishLaunchingWithOptions:
:The user will be asked to accept background download or not.
Take a look at this really complete tutorial about newsstand apps : http://www.viggiosoft.com/blog/blog/2011/10/17/ios-newsstand-tutorial/
This is what happens when content-available is in the payload:
There has to be an user action to start the application essentially by adding the alert message into the push notification.
source
http://samwize.com/2015/08/07/how-to-handle-remote-notification-with-background-mode-enabled/
However this doesn't solve your problem. As workaround you can use the background fetch, which wakes up the application every certain time interval.
Make sure, that UINewsstandApp = YES was set in your plist
{"aps": {"badge": 1, "alert": "test","content-available":1}}
This is a right payload.{"aps": {"badge": 1, "alert": "test"},"content-available":1}
This is a wrong payload.