Keep UILocalNotification Banner visible while app is in background

懵懂的女人 提交于 2019-12-12 04:47:57

问题


I'm working on a VoIP phone for iOS, and if a call comes in while running in the background, I do a presentLocalNotificationNow with a UILocalNotification message to inform the user. This works fine, however the banner expires and rolls off the screen before the user has enough of a chance to swipe and answer. I have tried scheduling further notifications at regular intervals, but that fills up the notification centre and causes the banner to appear to be tumbling.

Is there some way to prevent the banner from disappearing until I cancel it in some manner? Both the Skype app and Bria VoIP app have managed to come up with a solution where the banner stays until the call is answered, or the callee hangs up.


回答1:


The best way to do this is to add a sound to the local notification.

The default notification without a sound lasts 5 seconds as a banner, however you can include a sound that is longer, up to 30 seconds that you can play when the local notification is posted. The banner notification will stay on screen as long as the sound is playing.




回答2:


No. I think it is not possible to control/increment the hiding banner time to display. It is it's default behavior.

But instead of Banner style you can set Notification style as Alert. Which will not hide/disappear until user will click on alert's buttons.

Hope this will help.



来源:https://stackoverflow.com/questions/18370639/keep-uilocalnotification-banner-visible-while-app-is-in-background

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