简体   繁体   中英

iPhone push notification without alert

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.

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.

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]));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM