当应用程序在后台时保持 UILocalNotification Banner 可见 [英] Keep UILocalNotification Banner visible while app is in background

查看:29
本文介绍了当应用程序在后台时保持 UILocalNotification Banner 可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发适用于 iOS 的 VoIP 电话,如果在后台运行时有来电,我会使用 UILocalNotification 消息执行 presentLocalNotificationNow 以通知用户.这工作正常,但是横幅在用户有足够的机会滑动和回答之前过期并从屏幕上滚落.我曾尝试定期安排进一步的通知,但这会填满通知中心并导致横幅似乎在翻滚.

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.

在我以某种方式取消之前,有什么方法可以防止横幅消失吗?Skype 应用程序和 Bria VoIP 应用程序都设法提出了一种解决方案,即横幅一直保持到呼叫被接听或被叫方挂断为止.

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.

推荐答案

最好的方法是在本地通知中添加声音.

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

没有声音的默认通知作为横幅持续 5 秒,但是您可以包括当本地通知发布时,您可以播放更长的声音,最长可达 30 秒.只要声音在播放,横幅通知就会一直显示在屏幕上.

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.

这篇关于当应用程序在后台时保持 UILocalNotification Banner 可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆