-->

iOS的报刊亭:推送通知不启动后台应用程序(iOS newsstand: push notifica

2019-09-22 01:12发布

我执行报刊亭功能在应用程序中,虽然应用程序接收推送通知它不会在后台模式启动。
如果我点击该通知提醒的应用程序启动时,我可以看到“内容可用”:1出现在字典中,也是问题被下载,但应用程序不会自动启动。

我加入的plist:

<key>UIBackgroundModes</key>
<array>
    <string>newsstand-content</string>
</array>

并didFinishLaunchingWithOptions:

[[NSUserDefaults standardUserDefaults]setBool: YES forKey:@"NKDontThrottleNewsstandContentNotifications"]; // for testing purposes
    [[NSUserDefaults standardUserDefaults] synchronize];

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeNewsstandContentAvailability )];

我也看到我的应用程序没有设置下显示 - >销售 - >自动下载(等杂志在那里出现)。

我缺少的东西吗? 难道这在沙箱环境中工作?

Answer 1:

一些澄清

  1. 如果你没有在报亭有效载荷只具有内容可发送“警告”:在这1,什么也不会在通知中心得到补充。
  2. 报亭通知启动应用程序并不意味着应用程序将来到前台(如,如果用户点击过的应用程序图标)。 它只是意味着,如果应用没有在后台,它会被通过的iOS在后台启动 - >的appDelegate的didFinishLaunchingWithOptions被调用时,其中的应用程序应该检查它是否是一个报亭通知通过报亭队列增加资产安排该下载。 资产路径可以是NS有效载荷的一部分(设置<有效载荷极限256个字节)

的NSDictionary *有效载荷= [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

如果(有效载荷&& [[净荷objectForKey:kContentAvailablePush] caseInsensitiveCompare:@ “1”] == NSOrderedSame){的NSLog(@ “推出由于NS通知”); }



Answer 2:

您有报刊亭通知,以出现在设置并收到“报刊亭的通知”进行注册。 要注册,添加到您application:didFinishLaunchingWithOptions:

// Add registration for newsstand notifications
// In your application:didFinishLaunchingWithOptions:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
  UIRemoteNotificationTypeNewsstandContentAvailability];

该用户将被要求接受后台下载与否。

看看关于报刊亭应用这真的完全教程: http://www.viggiosoft.com/blog/blog/2011/10/17/ios-newsstand-tutorial/



Answer 3:

确保,即UINewsstandApp =在您的plist设置YES



Answer 4:

{"aps": {"badge": 1, "alert": "test","content-available":1}}这是一个正确的有效载荷。 {"aps": {"badge": 1, "alert": "test"},"content-available":1}这是一个错误的有效载荷。



Answer 5:

这是当内容可在有效载荷发生了什么:

  • 如果应用程序被暂停,系统将使其背景
  • 如果应用程序是由用户杀害没有任何反应和应用程序维持不运行

必须有一个用户操作为通过将警报消息发送到推送通知实质上启动应用程序。

资源

http://samwize.com/2015/08/07/how-to-handle-remote-notification-with-background-mode-enabled/

然而,这并不解决您的问题。 作为变通方法,您可以使用后台抓取,这唤醒应用每隔一定的时间间隔。



文章来源: iOS newsstand: push notification does not launch the app in background