iPhone push notification without alert

自古美人都是妖i 提交于 2019-12-11 10:05:15

问题


Is it possible to send a text push notification to an iPhone app without it popping up a modal dialog? I want it to go straight to the tray, like an Android notification. I know the notification tray can present notifications on iPhone very similarly to Android, but my research tells me the only way to get one there is to first have it pop up as a modal!

I'm creating a chat app, and a modal dialog popping up every time other people send messages (which could be every second) would be extremely annoying, but I need to have some way of letting the user know there are new messages. I don't think just incrementing the badge number is enough, since the app might not be on the home screen where they'll see it, and that provides no indication if the phone is locked (as far as I know). I don't actually have an iPhone and I've never used one, so maybe I'm way off base about what iPhone users expect.


回答1:


If you use APNS JSON, you can simply send null as body, and nothing will be presented to user. You can send "hidden" field, for your app purposes.

Or just set most preferred UIRemoteNotificationType (iOS 7) or UIUserNotificationSettings (iOS 8) for your notifications.




回答2:


If you send null as body and null as sound it will be unnnoticable. For example you can update the badge without notifing the user

In php using the following package https://github.com/davibennun/laravel-push-notification it would work this way

PushNotification::app(APP_ID)
->to(TARGET_DEVICE_ID)
->send(PushNotification::Message(null, ['badge'  => 90, 'sound'  => null]));


来源:https://stackoverflow.com/questions/25939606/iphone-push-notification-without-alert

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