ios - APNs 远程通知委托(delegate)方法未被调用

标签 ios iphone push-notification apple-push-notifications

我们有一款设计为在iOS7 上运行的应用程序。我们已经安装了 PersistentConnectionLogging 配置文件以进一步调试我们的问题(如 Trouble Shooting Push Notifications technical note 中所述)。

我们已确认手机通过蜂窝调制解调器(禁用 WiFi)具有完整且有效的 3G 互联网连接,该应用程序允许在设置中进行远程通知,并且在许多其他运行完全相同构建的设备上成功运行同型号手机(iPhone 4S)。手机还受到 MDM 服务的监管。

正在工作的手机上,它是这样的(试图挑选出有用的控制台消息),

Nov 17 11:15:14 MDM-Test-Phone-2 TestApp[546] <Warning>: >>>>>>>> APP LAUNCHED <<<<<<<<

....

Nov 17 11:15:15 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:15:15 -0500 apsd[82]: peer(34) received XPC_ERROR_CONNECTION_INVALID

...

Nov 17 11:15:15 calling, [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeNewsstandContentAvailability];

...

Nov 17 11:15:15 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:15:15 -0500 apsd[82]: Looking up connection on peer: 15d71590  found <APSConnectionServer: 0x15db0a00>
Nov 17 11:15:15 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:15:15 -0500 apsd[82]:    <APSCourier: 0x15d658d0>: Received request from <APSConnectionServer: 0x15db0a00> to generate token for topic "com.test.test" and identifier ""
Nov 17 11:15:15 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:15:15 -0500 apsd[82]: copyTokenForDomain sandbox.push.apple.com ,fffffff7ffffff93ffffffe039604451ffffff8cffffffccffffff80ffffffe75c0affffffe0ffffffcf5d4dffffff8cffffffa41a
Nov 17 11:15:15 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:15:15 -0500 apsd[82]: <APSCourier: 0x15d658d0> found cached token <c150ca2f 039dc8fb a642ac22 47d8f80b abc9d186 0811a083 a4820d99 d749c09b> for appSpecificIdentifier ,fffffff7ffffff93ffffffe039604451ffffff8cffffffccffffff80ffffffe75c0affffffe0ffffffcf5d4dffffff8cffffffa41a
Nov 17 11:15:15 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:15:15 -0500 apsd[82]: <APSCourier: 0x15d658d0> handleReceivedPublicToken: <c150ca2f 039dc8fb a642ac22 47d8f80b abc9d186 0811a083 a4820d99 d749c09b> forTopic com.test.test identifier 
Nov 17 11:15:15 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:15:15 -0500 apsd[82]: Dispatching low priority message: <OS_xpc_dictionary: <dictionary: 0x15dc1660> { count = 4, contents =
    "identifier" => <string: 0x15db2060> { length = 0, contents = "" }
    "message-type" => <int64: 0x15dbb460>: 21
    "topic" => <string: 0x15d9a800> { length = 22, contents = "com.test.test" }
    "token" => <data: 0x15dbd9d0>: { length = 32 bytes, contents = 0xc150ca2f039dc8fba642ac2247d8f80babc9d1860811a083... }
}>

...

didRegisterForRemoteNotificationsWithDeviceToken successfully called

...

Nov 17 11:24:41 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-11-17 11:24:41 -0500 apsd[82]: _getClientIdentity: already had identity: <SecIdentityRef: 0x15da1850>

但是,在无法正常工作的手机上,情况是这样的,

Oct 23 10:50:55 MDM-Test-Phone-2 TestApp[145] <Warning>: >>>>>>>> APP LAUNCHED <<<<<<<<
Oct 23 10:50:56 MDM-Test-Phone-3 apsd[82] <Warning>: 2014-10-23 10:50:56 -0400 apsd[82]: peer(34) received XPC_ERROR_CONNECTION_INVALID
Oct 23 10:50:56 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:50:56 -0400 apsd[82]: _getClientIdentity: already had identity: <SecIdentityRef: 0x14dbcc20>
Oct 23 10:50:56 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:50:56 -0400 apsd[82]: peer(34) received XPC_ERROR_CONNECTION_INVALID

...

Oct 23 10:50:56 calling, [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeNewsstandContentAvailability];

...

Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82]: Interface manager: WWAN radio power level notification; DCH status changed to inactive
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82]: <APSCourier: 0x14db94b0> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to NO
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82]: <APSTopicManager: 0x14db9930> isPowerEfficientToSendFilter changed to NO
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82]: <APSCourier: 0x14d74090> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to NO
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82]: <PCInterfaceUsabilityMonitor: 0x14d44ad0> [WWAN](pdp_ip0): isInterfaceUsable? YES reachable YES linkQuality 100 isNetworkCaptive? NO
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> calculating _earlyFireDate. powerStateDetectionSupported = YES = (detectionSupported(YES) && (wwanIsUp(YES) || ! internetReachable(YES)))
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Device is plugged in, overriding earlyFireProportion to be 1.0
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Calculated minimum fire date [2014-10-23 16:50:34 -0400] (98.1318%) with fire date [2014-10-23 16:57:34 -0400], start date [2014-10-23 10:42:52 -0400], minimum early fire proportion 0.981318, power state detection supported: yes, in high power state: no
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82]: <PCInterfaceUsabilityMonitor: 0x14d44ad0> [WWAN](pdp_ip0): isInterfaceUsable? YES reachable YES linkQuality 100 isNetworkCaptive? NO
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> calculating _earlyFireDate. powerStateDetectionSupported = YES = (detectionSupported(YES) && (wwanIsUp(YES) || ! internetReachable(YES)))
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> Device is plugged in, overriding earlyFireProportion to be 1.0
Oct 23 10:51:05 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:05 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> Calculated minimum fire date [2014-10-23 11:24:44 -0400] (100%) with fire date [2014-10-23 11:24:44 -0400], start date [2014-10-23 10:43:51 -0400], minimum early fire proportion 0, power state detection supported: yes, in high power state: no
Oct 23 10:51:07 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:07 -0400 apsd[82] interfacemanager-wifiautoassoc: SimpleTimer <PCSimpleTimer: 0x14d72cd0> has fired
Oct 23 10:51:07 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:07 -0400 apsd[82] interfacemanager-wifiautoassoc: Invalidating simple timer <PCSimpleTimer: 0x14d72cd0>
Oct 23 10:51:07 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:07 -0400 apsd[82]: Disabling power monitoring for <PCSimpleTimer: 0x14d72cd0> - 5 timers
Oct 23 10:51:20 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:20 -0400 apsd[82] interfacemanager-wow: SimpleTimer <PCSimpleTimer: 0x14d561e0> has fired
Oct 23 10:51:20 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:20 -0400 apsd[82] interfacemanager-wow: Invalidating simple timer <PCSimpleTimer: 0x14d561e0>
Oct 23 10:51:20 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:20 -0400 apsd[82]: Disabling power monitoring for <PCSimpleTimer: 0x14d561e0> - 4 timers
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82]: Interface manager: WWAN radio power level notification; DCH status changed to active
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82]: <APSCourier: 0x14db94b0> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to YES
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82]: <APSTopicManager: 0x14db9930> isPowerEfficientToSendFilter changed to YES
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82]: <APSCourier: 0x14d74090> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to YES
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82]: <PCInterfaceUsabilityMonitor: 0x14d44ad0> [WWAN](pdp_ip0): isInterfaceUsable? YES reachable YES linkQuality 100 isNetworkCaptive? NO
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> calculating _earlyFireDate. powerStateDetectionSupported = YES = (detectionSupported(YES) && (wwanIsUp(YES) || ! internetReachable(YES)))
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Device is plugged in, overriding earlyFireProportion to be 1.0
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Calculated minimum fire date [2014-10-23 16:50:34 -0400] (98.1318%) with fire date [2014-10-23 16:57:34 -0400], start date [2014-10-23 10:42:52 -0400], minimum early fire proportion 0.981318, power state detection supported: yes, in high power state: yes
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82]: <PCInterfaceUsabilityMonitor: 0x14d44ad0> [WWAN](pdp_ip0): isInterfaceUsable? YES reachable YES linkQuality 100 isNetworkCaptive? NO
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> calculating _earlyFireDate. powerStateDetectionSupported = YES = (detectionSupported(YES) && (wwanIsUp(YES) || ! internetReachable(YES)))
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> Device is plugged in, overriding earlyFireProportion to be 1.0
Oct 23 10:51:28 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:28 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> Calculated minimum fire date [2014-10-23 11:24:44 -0400] (100%) with fire date [2014-10-23 11:24:44 -0400], start date [2014-10-23 10:43:51 -0400], minimum early fire proportion 0, power state detection supported: yes, in high power state: yes
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82]: Interface manager: WWAN radio power level notification; DCH status changed to inactive
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82]: <APSCourier: 0x14db94b0> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to NO
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82]: <APSTopicManager: 0x14db9930> isPowerEfficientToSendFilter changed to NO
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82]: <APSCourier: 0x14d74090> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to NO
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82]: <PCInterfaceUsabilityMonitor: 0x14d44ad0> [WWAN](pdp_ip0): isInterfaceUsable? YES reachable YES linkQuality 100 isNetworkCaptive? NO
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> calculating _earlyFireDate. powerStateDetectionSupported = YES = (detectionSupported(YES) && (wwanIsUp(YES) || ! internetReachable(YES)))
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Device is plugged in, overriding earlyFireProportion to be 1.0
Oct 23 10:51:36 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:36 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Calculated minimum fire date [2014-10-23 16:50:34 -0400] (98.1318%) with fire date [2014-10-23 16:57:34 -0400], start date [2014-10-23 10:42:52 -0400], minimum early fire proportion 0.981318, power state detection supported: yes, in high power state: no
Oct 23 10:51:37 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:37 -0400 apsd[82]: <PCInterfaceUsabilityMonitor: 0x14d44ad0> [WWAN](pdp_ip0): isInterfaceUsable? YES reachable YES linkQuality 100 isNetworkCaptive? NO
Oct 23 10:51:37 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:37 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> calculating _earlyFireDate. powerStateDetectionSupported = YES = (detectionSupported(YES) && (wwanIsUp(YES) || ! internetReachable(YES)))
Oct 23 10:51:37 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:37 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> Device is plugged in, overriding earlyFireProportion to be 1.0
Oct 23 10:51:37 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:37 -0400 apsd[82] com.apple.apsd(push.apple.com)-WWAN: <PCPersistentTimer: 0x14d5bad0> Calculated minimum fire date [2014-10-23 11:24:44 -0400] (100%) with fire date [2014-10-23 11:24:44 -0400], start date [2014-10-23 10:43:51 -0400], minimum early fire proportion 0, power state detection supported: yes, in high power state: no
Oct 23 10:51:55 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:55 -0400 apsd[82]: Screen did lock (Was unlocked for 100.329434 seconds)
Oct 23 10:51:55 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:55 -0400 apsd[82]: Delivering systemDidLock to <APSNetworkMonitor: 0x14d7da10>
Oct 23 10:51:55 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:55 -0400 apsd[82]: <APSNetworkMonitor: 0x14d7da10> systemDidLock, refreshing state
Oct 23 10:51:55 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:55 -0400 apsd[82]: Delivering systemDidLock to <APSNetworkMonitor: 0x14db95c0>
Oct 23 10:51:55 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:55 -0400 apsd[82]: <APSNetworkMonitor: 0x14db95c0> systemDidLock, refreshing state
Oct 23 10:51:55 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:55 -0400 apsd[82]: Delivering systemDidLock to <APSCourier: 0x14d74090>
Oct 23 10:51:55 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:55 -0400 apsd[82]: Delivering systemDidLock to <APSCourier: 0x14db94b0>
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82]: Interface manager: WWAN radio power level notification; DCH status changed to active
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82]: <APSCourier: 0x14db94b0> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to YES
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82]: <APSTopicManager: 0x14db9930> isPowerEfficientToSendFilter changed to YES
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82]: <APSCourier: 0x14d74090> <PCInterfaceMonitor: 0x14d7c5f0> interface radio hotness changed to YES
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82]: <PCInterfaceUsabilityMonitor: 0x14d44ad0> [WWAN](pdp_ip0): isInterfaceUsable? YES reachable YES linkQuality 100 isNetworkCaptive? NO
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> calculating _earlyFireDate. powerStateDetectionSupported = YES = (detectionSupported(YES) && (wwanIsUp(YES) || ! internetReachable(YES)))
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Device is plugged in, overriding earlyFireProportion to be 1.0
Oct 23 10:51:57 MDM-Test-Phone-2 apsd[82] <Warning>: 2014-10-23 10:51:57 -0400 apsd[82] com.apple.Duet.APLSScheduler: <PCPersistentTimer: 0x14dac940> Calculated minimum fire date [2014-10-23 16:50:34 -0400] (98.1318%) with fire date [2014-10-23 16:57:34 -0400], start date [2014-10-23 10:42:52 -0400], minimum early 

很明显,在正在工作的手机上,“在对等端查找连接”在注册远程通知后会立即触发。如果在调试 APNs 控制台消息方面具有更多专业知识的人注意到任何突出的内容或对如何继续调试有任何建议,我很乐意听取您的意见!

最佳答案

我看到了完全相同的问题,并且有一个工作理论,它与后台电源使用有关,并且可能与 beginBackgroundTaskWithExpirationHandler 的使用有关。 iOS 可能会根据其保存的某种类型的电量使用指标来决定是否唤醒应用程序。

相关:iOS UIBackgroundMode remote-notification doesn't work on 4G

或者这只是 iOS 中的一个错误。不管怎样,绝对没有记录,而且是一个主要的皮塔饼。

关于ios - APNs 远程通知委托(delegate)方法未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26532241/

相关文章:

ios - 如何将 UIView 链接到 UICollectionViewCell?

iphone - 如何初始化 AVCaptureMetadataOutput 对象?

iphone - 在适用于 iOS 的 AdHoc 分发版本上使用沙盒 APNS

iphone - 推送通知 token 在单个设备的所有应用程序中是否唯一?

ios - willPresentNotification 无法按预期工作

iOS std::length_error::~length_error() 崩溃

ios - 将 Team Foundation Server (TFS) 与 Xcode 连接起来

ios - 更改单元格 AccessoryView

iphone - iPad : Crash because of add more than three CCSpriteFrameCache file

iphone - 实现点击任意位置即可取消的最佳方式(App Store 下载按钮)?