Apple推送通知守护程序没有为运行Mac应用程序提供远程通知?

时间:2016-05-09 19:38:14

标签: macos apple-push-notifications

OS X上的Apple Push通知守护程序(apsd)不会向正在运行的应用程序发送远程通知。

我已验证我的应用已成功注册通知并收到有效的设备令牌。这是从守护程序到正在运行的应用程序的“最后一英里”的问题。

Apple的技术说明显示了打开日志记录的方法:

sudo defaults write /Library/Preferences/com.apple.apsd APSWriteLogs -bool TRUE
sudo defaults write /Library/Preferences/com.apple.apsd APSLogLevel -int 7
sudo killall apsd

如果我这样做,我会看到该守护进程接收并处理该消息:

May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSCourier: 0x7fdd82e43790>: Received high priority message for topic '<MY BUNDLE ID>' with payload '<CFBasicHash 0x7fdd82c3a7a0 [0x7fff72f8d890]>{type = immutable dict, count = 2,
entries =>
    0 : aps = <CFBasicHash 0x7fdd82c50540 [0x7fff72f8d890]>{type = immutable dict, count = 1,
entries =>
    2 : <CFString 0x7fdd82c31100 [0x7fff72f8d890]>{contents = "content-available"} = <CFNumber 0x137 [0x7fff72f8d890]>{value = +1, type = kCFNumberSInt64Type}
}

    1 : userkey = <CFString 0x7fdd82c3eed0 [0x7fff72f8d890]>{contents = "<CUSTOM DATA>"}
}
'
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSMessageStore: 0x7fdd82f1a590> asked to store incoming message <APSIncomingMessage: 0x7fdd82c05520> with guid DEE95AE0-8936-4D07-9874-326CA5EA5D25 environment <APSEnvironment: 0x7fdd82c181e0: development>
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSCourier: 0x7fdd82e43790>: Stream processing: complete no, invalid no, length parsed 0, parameters (null)
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: APSMessageStore - New message record [<APSIncomingMessageRecord 0x7fdd82c41a70 [0x7fff72f8d890]>{}] has ID [23161].
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSMessageStore: 0x7fdd82f1a590> calling completion block for incoming message DEE95AE0-8936-4D07-9874-326CA5EA5D25
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSCourier: 0x7fdd82e43790>: Sending acknowledgement message with response 0 and messageId <00000000> (0)
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSCourier: 0x7fdd82e43790> _notifyForIncomingMessage <APSIncomingMessage: 0x7fdd82c05520> with guid DEE95AE0-8936-4D07-9874-326CA5EA5D25
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: Dispatching high priority message: <OS_xpc_dictionary: <dictionary: 0x7fdd82f19340> { count = 2, contents =
    "message" => <dictionary: 0x7fdd82f250f0> { count = 1, contents =
        "ECF19A18-7AA6-4141-B4DC-A2E5123B2B5C" => <data: 0x7fdd82f19f70>: { length = 4096 bytes, contents = 0x62706c69737431351396010000000000801200000000d87f... }
    }
    "message-type" => <int64: 0x7fdd82f1e670>: 26
}>
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSCourier: 0x7fdd82e43790> informed that <APSConnectionServer: 0x7fdd82d50da0> acknowledges incoming message with guid DEE95AE0-8936-4D07-9874-326CA5EA5D25
May  9 15:17:16 ML-C02MJHRAFH00 apsd[88]: <APSMessageStore: 0x7fdd82f1a590> Removing incoming message with guid DEE95AE0-8936-4D07-9874-326CA5EA5D25

这曾经工作正常,我会看到在我正在运行的应用程序中调用的didReceiveRemoteNotification方法。突然它停止了工作。我已经尝试清除lsregister数据库了。我的包标识符与正在运行的应用程序匹配。

0 个答案:

没有答案