You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS Ventura下APNs已送达但Mac应用未接收推送问题求助

macOS Ventura升级后OTP配套应用无法接收APNS推送通知

问题背景

我开发了一款iOS一次性密码(OTP)应用,以及对应的macOS配套应用。完整流程为:

iOS应用 -> HTTP请求 -> 我的服务器 -> APS(Apple推送服务) -> macOS应用

用户在iOS端点击一次性密码后,会触发上述流程,服务器向macOS应用发送包含OTP的推送通知(全程加密,此点与当前问题无关)。

近期用户升级到macOS Ventura后,macOS应用完全停止接收通知。我已验证从iOS应用到服务器再到APS的流程均正常,APS返回200 OK状态码,说明推送通知已发送至macOS设备,但macOS应用的didReceiveRemoteNotification函数始终未触发。

相关代码验证

推送接收回调(未触发)

/// 运行中的应用收到远程通知时通知代理
///
/// - Parameter application: 接收远程通知的应用
/// - Parameter userInfo: 包含远程通知相关信息的字典,包括应用图标角标数、通知标识符及可能的自定义数据
func application(_ application: NSApplication, didReceiveRemoteNotification userInfo: [String : Any]) {
    NotificationHelper.shared.notify(userInfo)
    
    log.verbose("在应用代理中收到远程通知。")
}

设备Token注册回调(正常工作)

调试日志确认APNS注册成功:

/// Apple推送服务成功完成注册流程时通知代理
///
/// - Parameter application: 发起远程通知注册流程的应用
/// - Parameter deviceToken: 标识设备的令牌,用于APNS识别设备
func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    settingsView.pushToken.data = deviceToken
    linkingView.pushToken.data = deviceToken
    
    log.verbose("APNS注册流程成功完成。")
}

已排除的可能性

  • 使用的是APS生产密钥,macOS应用为TestFlight生产构建版本,在用户升级Ventura前,相同的密钥和构建版本一直正常工作。

Console.app异常日志信息

虽然Xcode或生产构建的调试日志中无相关输出,但macOS的Console.app显示推送通知已被接收,其中关键错误日志如下:

error   20:35:11.556008+0100    apsd    <private>: Received message for unknown token '<private>'
error   20:35:11.556068+0100    apsd    <private>: Ignoring duplicate message received with topic: '<private>' timestamp=1671564911431255965 (57.5 seconds ago)

完整异常APS日志:

default 20:35:11.555463+0100    apsd    <private>: Outstanding data received: <private> (length 490)
default 20:35:11.555624+0100    apsd    <private>: Stream processing: complete yes, invalid no, length parsed 490, parameters <private>
default 20:35:11.555761+0100    apsd    <private>: Failed to find token name for unrecognized token <private>
default 20:35:11.555876+0100    apsd    <private>: Message has token <private> (tokenName (null))
error   20:35:11.556008+0100    apsd    <private>: Received message for unknown token '<private>'
error   20:35:11.556068+0100    apsd    <private>: Ignoring duplicate message received with topic: '<private>' timestamp=1671564911431255965 (57.5 seconds ago)
default 20:35:11.556186+0100    apsd    APSPowerLog: {event: <private>, dict: <private>}
default 20:35:11.556432+0100    apsd    <private>: Sending acknowledgement message with response 7 and messageId <private> (3889788835)
default 20:35:11.556591+0100    apsd    <private>: Sending Push ACK. UUID: (null)
default 20:35:11.556735+0100    apsd    <private>: Stream processing: complete no, invalid no, length parsed 0, parameters (null)

正常工作时的APS日志对比

推送通知正常接收的用户,Console.app会显示以下日志:

default 16:00:48.398808+0100    apsd    <private>: Message has token <private> (tokenName <private>)
default 16:00:48.398969+0100    apsd    <private>: Received message for enabled topic '<private>' onInterface: NonCellular with payload '<private>' with priority 5
default 16:00:48.399208+0100    apsd    <private>: Push has been read from stream and parsed. UUID: (null)
default 16:00:48.399323+0100    apsd    APSPowerLog: {event: <private>, dict: <private>}
default 16:00:48.399481+0100    apsd    <private> asked to store incoming message <private> with guid <private> environment <private>
default 16:00:48.401221+0100    apsd    APSMessageStore - New message record [<private>] has ID [16196].
default 16:00:48.401381+0100    apsd    <private>: Sending acknowledgement message with response 0 and messageId <private> (37785720)
default 16:00:48.401473+0100    apsd    <private>: Sending Push ACK. UUID: (null)

补充信息

应用为开源项目,涉及APS服务器脚本、macOS应用代码,且已有用户在相关Issue中共同调试。

欢迎提供任何关于macOS应用无法正确接收通知的思路,希望能找到解决方案。


内容的提问来源于stack exchange,提问作者Tijme

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 19:10:29