iOS silent push notification cancelled

早过忘川 提交于 2021-02-05 07:44:32

问题


In my application, I use silent push notification in order to communicate regularly, but I am in trouble because the silent push notification I received while not launching the application is not processed. OS version is iOS12. I am using FCM to send push notifications. Is there anyone with the same problem?

Below is the console log when you receive a notification silent push notification.

10:41:09.395630 +0900    apsd    <APSPushHistory: 0x135ee6fe0> timestampForTopic? ##my.app.bundleidentifier## token <##token##>
10:41:09.410548 +0900    apsd    <APSPushHistory: 0x135ee6fe0> hasPayload? <##payload##> forTopic ##my.app.bundleidentifier## tokens (
    <##token##>
)
10:41:09.428957 +0900    apsd    copyAppSpecificTokensWithDomain - sandbox.push.apple.com for topic ##my.app.bundleidentifier## account ##account##
10:41:09.429047 +0900    apsd    <APSPushHistory: 0x135ee6fe0> receivedPushWithTopic ##my.app.bundleidentifier## token <##token##> payload <##payload##> timestamp Thu Dec 13 10:41:09 2018
10:41:09.429660 +0900    apsd    <APSCourier: 0x135ed8f50>: Received message for enabled topic '##my.app.bundleidentifier##' onInterface: NonCellular with payload '{
    aps =     {
        "content-available" = 1;
    };
    "gcm.message_id" = "##gcm.message_id##";
}' with priority 5 for device token: NO
10:41:09.439475 +0900    SpringBoard    <APSConnection: 0x2804c4480> Delivering message from apsd: <APSIncomingMessage: 0x283cd4ab0> 1641282366 ##my.app.bundleidentifier##
10:41:09.440909 +0900    SpringBoard    <APSConnection: 0x2804c4480> making delegate (<UNSRemoteNotificationServer: 0x2800c19a0>) calls to deliver message 1641282366 {
    aps =     {
        "content-available" = 1;
    };
    "gcm.message_id" = "0:1544665268470982%cdf8ec08cdf8ec08";
} for topic ##my.app.bundleidentifier##
10:41:09.441303 +0900    SpringBoard    Received incoming message on topic ##my.app.bundleidentifier## at priority 1
10:41:09.442552 +0900    SpringBoard    [##my.app.bundleidentifier##] Received remote notification request A9C2-0C29 [ hasAlertContent: 0, hasSound: 0 hasBadge: 0 hasContentAvailable: 1 hasMutableContent: 0 ]
10:41:09.442651 +0900    SpringBoard    [##my.app.bundleidentifier##] Deliver push notification A9C2-0C29
10:41:09.442749 +0900    SpringBoard    [##my.app.bundleidentifier##] Request DUET delivers content-available push notification to application
10:41:09.443031 +0900    SpringBoard    [##my.app.bundleidentifier##] Not delivering user visible notification A9C2-0C29 because it has no alert, sound or badge
10:41:09.443141 +0900    SpringBoard    [##my.app.bundleidentifier##] Not delivering user visible push notification A9C2-0C29 [ error=Error Domain=UNErrorDomain Code=1401 "Notification has no user visible content" UserInfo={NSLocalizedDescription=Notification has no user visible content} ]
10:41:09.444107 +0900    dasd    Submitted Activity: com.apple.pushLaunch.##my.app.bundleidentifier##:A9B065 <private>
10:41:09.446320 +0900    dasd    Daemon Canceling Activities: {(
    com.apple.pushLaunch.##my.app.bundleidentifier##:A9B065
)}
0:41:09.446567 +0900    dasd    CANCELED: com.apple.pushLaunch.##my.app.bundleidentifier##:A9B065 <private>!
10:44:50.932320 +0900    locationd    {"msg":"client getting effective client name", "bundleId":"##my.app.bundleidentifier##", "bundlePath":""}

回答1:


I had a similar issue. I eventually discovered that disabling background refresh also disables the delivery of silent notifications to suspended apps.

In this case, if you enable background refresh, does iOS launch your app and deliver the notification to your app delegate?




回答2:


In my case the problem was the lake of other properties in the payload. I was using this payload at the beggining:

{"aps":{"content-available":1}}

but adding the Sound property fixed the problem:

{"aps":{"content-available":1, "sound":""}}


来源:https://stackoverflow.com/questions/53772983/ios-silent-push-notification-cancelled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!