2

如果我尝试在 iOS 11 上发送无声推送通知(没有徽章/声音/警报)并且只有内容可用,根据无声通知的规范,通知将被忽略并且不会转发到应用程序。

这是通知

{
    "aps" : {
        "content-available" : 1,
    }, 
    "type" : "0"
}

设备日志有:

<Error>: Ignoring notification with no alert, sound or badge (it.my.app.dev): C146-3838

更完整:

Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Received remote notification request C146-3838 [ hasAlertContent: 0, hasSound: 0 hasBadge: 0 hasContentAvailable: 1 hasMutableContent: 0 ]
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Deliver push notification request C146-3838
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Passing content-available push to Duet
Dec 27 10:11:30 iPierX SpringBoard(DuetActivityScheduler)[59] <Notice>: SUBMITTING: <private>
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Error>: Ignoring notification with no alert, sound or badge (it.my.app.dev): C146-3838
Dec 27 10:11:30 iPierX SpringBoard(UserNotificationsServer)[59] <Notice>: [it.my.app.dev] Not saving push notification C146-3838 to store [ error=Error Domain=UNErrorDomain Code=1401 "Notification has no user-facing content" UserInfo={NSLocalizedDescription=Notification has no user-facing content} ]
Dec 27 10:11:30 iPierX dasd(DuetActivitySchedulerDaemon)[1645] <Notice>: Submitted Activity: com.apple.pushLaunch.it.my.app.dev:EA2367 <private>
Dec 27 10:11:30 iPierX dasd(DuetActivitySchedulerDaemon)[1645] <Notice>: Daemon Canceling Activities: {(
    com.apple.pushLaunch.it.my.app.dev:EA2367
)}
Dec 27 10:11:30 iPierX dasd(DuetActivitySchedulerDaemon)[1645] <Notice>: CANCELED: com.apple.pushLaunch.it.my.app.dev:EA2367 <private>
4

2 回答 2

1

好的..过了一会儿,和一些苹果工程师聊天,在这里,我让它工作了。关键是将通知设置为高优先级作为交付优先级,以及content-available = 1.

当然,静默推送通知有通常的速率限制,但总体而言它按预期工作。

于 2018-04-17T11:26:00.547 回答
1

这也有效,并且在到达时不会播放声音:

{
    aps = {
        "content-available" : 1,
        sound : ""
    };
}
于 2017-12-27T10:12:21.560 回答