Is it possible to send a “silent” push notification on iPhone (without any alert to the user)?

南笙酒味 提交于 2019-12-04 08:26:49

Yes, increment only badge number, dont send sound and alert, So, there will be one badge on the App icon.

So, here unknowingly the badge number will be incremented to show that something has been recieved when user watches the app icon.

But your device won't recive alert or empty payload and won't recieve sound also because you asked for “silent” push notification on iPhone

and while configuring in AppDelegate, configure only badges

 [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge];

Hope this will be helpful for you

You need to build the payload like this:

String payload = 
'{
    "aps":{
        "content-available": 1 
    }, 
    "data_id": 5, 
    "additional_data": ["some", "data"]
}'

In aps put the apple variales needed to make the push notification display a text, sound, badge... or just content-available to make it silent. Then, out of 'aps{...}' and separated with ',' put your custom fields to send the needed information for the download.

If you don't want the badge number to increase you could also try sending a sound notification which plays a silent sound file. (Unfortunately, I don't know if this is ok for Apple).

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