我们在使用Xcode 4构建的商店上有一个报亭应用程序。我们注意到,当应用程序在后台时,远程通知不再转发到运行iOS 7的设备的应用程序。 如果设备在前台,则接收并处理通知。
此外,这些通知在运行iOS 6及更早版本的设备上进行适当处理和处理。
通过在设备上启用持久性日志记录,我们可以看到iOS 7设备收到通知,但是从未调用- [UIApplication application: didReceiveRemoteNotification:] 。
评估运行iOS 5/6/7的设备的设备日志,我们会看到远程通知:
Oct 24 11:24:22 iPad-Retina apsd[82] <Warning>: 2013-10-24 11:24:22 +0200 apsd[82]: <APSCourier: 0x14d8c7b0>: Received message for enabled topic 'com.companyname.ourapp' with payload '{ aps = { "content-available" = 1; importantInformation = @"23"; sound = ""; }; }' onInterface: NonCellular for device token: NO with priority (null)在iOS 7上,此通知不会转发到应用程序,但在早期版本的iOS上,我们会看到对以下方法的调用:
Oct 24 11:24:20 Pad2-3G Magic[1328] <Warning>: -[ApplicationDelegate application:didReceiveRemoteNotification:]我们的报摊通知已成功处理。
我们有什么办法可以确保使用iOS 6 SDK成功地为iOS 7设备提供报刊下载操作?
在我们重新设计应用程序之前,至少暂时不需要使用Xcode 5以及iOS 7 SDK的答案。
提前致谢
We have a newsstand app on the store built using Xcode 4. We have noticed that remote notifications are no longer forwarded to our app for devices running iOS 7 when the app is in the background. If the device is in the foreground, the notification is received and handled.
Furthermore, these notifications are processed and handled appropriately on devices running iOS 6 and earlier.
With persistent logging enabled on the device we can see that the iOS 7 device receives the notification however - [UIApplication application: didReceiveRemoteNotification:] is never called.
Assessing the device logs for devices running iOS 5/6/7, we see the remote notification coming in:
Oct 24 11:24:22 iPad-Retina apsd[82] <Warning>: 2013-10-24 11:24:22 +0200 apsd[82]: <APSCourier: 0x14d8c7b0>: Received message for enabled topic 'com.companyname.ourapp' with payload '{ aps = { "content-available" = 1; importantInformation = @"23"; sound = ""; }; }' onInterface: NonCellular for device token: NO with priority (null)On iOS 7 this notification is not forwarded to the app but, on earlier versions of iOS, we see a call to the following method:
Oct 24 11:24:20 Pad2-3G Magic[1328] <Warning>: -[ApplicationDelegate application:didReceiveRemoteNotification:]and our newsstand notification is processed successfully.
Is there any way we can ensure a successful newsstand download operation for iOS 7 devices using the iOS 6 SDK?
An answer that doesn't involve using Xcode 5 and thus the iOS 7 SDK is preferable at least for now until we do an app redesign.
Thanks in advance
最满意答案
我们设法使用以下假设来解决问题:
iOS 7引入了-application:didReceiveRemoteNotification:fetchCompletionHandler:在UIApplicationDelegate ,我们假设可能没有收到通知的原因是iOS正在测试应用程序委托是否响应更新的选择器。
自然地,Xcode 4没有UIBackgroundFetchResult因此可以使用NSUInteger简单地实现该方法。 所以我们在应用程序委托中添加了该方法:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(NSUInteger result))handler { [self application:application didReceiveRemoteNotification:userInfo]; handler(0); }此外,我们必须在应用程序plist中向UIBackgroundModes添加远程通知。
使用Xcode 4在任何iOS 7设备上构建代码成功解决了问题并允许我们提交到商店。
我希望这个答案可以帮助那些处于同一位置的人
We managed to resolve the issue using the following, assumption:
iOS 7 introduced -application:didReceiveRemoteNotification:fetchCompletionHandler: in the UIApplicationDelegate, we made an assumption that perhaps the reason the notification was not being received was that iOS was testing to see if the application delegate responds to the newer selector.
Naturally Xcode 4 does not have UIBackgroundFetchResult so the method could simply be implemented using an NSUInteger. So we added the method in our application delegate:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(NSUInteger result))handler { [self application:application didReceiveRemoteNotification:userInfo]; handler(0); }Furthermore, we had to add remote-notification to UIBackgroundModes in the application plist.
Building the code using Xcode 4 onto any iOS 7 device successfully resolved the issue and allowed us to submit to the store.
I hope this answer helps anyone else who was in the same position
更多推荐
发布评论