简体   繁体   English

iOS UILocalNotification用于传入SIP通知

[英]iOS UILocalNotification for incomming sip notification

After getting sip notification how to show it to user using UILocalNotification when app is in background. 收到UILocalNotification通知后,当应用程序在后台UILocalNotification时,如何使用UILocalNotification将其显示给用户。

App's Background mode is ->voip and it is always alive in background . 应用程序的Background mode is ->voip ,并且always alive in background

just it can not show notification after getting sip call when it is in background. 只是在后台通话时无法显示通知。

It's a little difficult to tell what your question is, but I can tell you that a UILocalNotification will present itself to the user exactly as is described in Apple's documentation at "Local and Push Notification Programming Guide" > "Handling Local and Remote Notifications". 很难说出您的问题是什么,但是我可以告诉您,UILocalNotification会完全按照Apple文档 “本地和推送通知编程指南”>“处理本地和远程通知”中的描述向用户展示自己。 Specifically: 特别:

  1. If your app is in the background or has been terminated, iOS will display the local notification for you using the properties defined when the UILocalNotification was created & configured. 如果您的应用程序在后台或已终止,iOS将使用在创建和配置UILocalNotification时定义的属性为您显示本地通知。
  2. If your app is in the foreground, iOS won't automatically display your notification -- you must implement UIApplicationDelegate's -application:didReceiveLocalNotification: and present (or not present) the notification as you see fit. 如果您的应用程序位于前台,iOS不会自动显示您的通知-您必须实现UIApplicationDelegate的-application:didReceiveLocalNotification:并在您认为合适的情况下显示(或不显示)通知。

And don't forget forget to actually schedule your UILocalNotification with -[UIApplication sharedApplication] using the -scheduleLocalNotification: method. 并且不要忘记使用-scheduleLocalNotification:方法使用-[UIApplication sharedApplication]实际调度UILocalNotification。 Just creating the UILocalNotification won't do anything. 仅创建UILocalNotification不会做任何事情。

AND, I think you need to use UIApplication's -registerForRemoteNotificationTypes: even for local notifications. 而且,我认为您甚至需要使用UIApplication的-registerForRemoteNotificationTypes:甚至用于本地通知。

Just as an aside unrelated to Local Notifications, because we struggled with VOIP backgrounding as well, note that just because you set the Background mode to VOIP, doesn't mean your app will always be running. 除了与本地通知无关之外,由于我们也对VOIP背景进行了挣扎,请注意,仅仅因为您将“背景”模式设置为VOIP,并不意味着您的应用将始终运行。 Any of the following will lead to iOS terminating your app: 以下任何一项都会导致iOS终止您的应用程序:

  • You use UDP for your VOIP socket. 您将UDP用于VOIP套接字。 iOS doesn't appear to support backgrounding with UDP, only TCP. iOS似乎不支持UDP背景,仅支持TCP。
  • If your VOIP socket connection receives more than 30 "wakes" within 300 seconds. 如果您的VOIP套接字连接在300秒内收到30次以上的“唤醒”。
  • If your VOIP socket is disconnected, you must request background execution time while you attempt to reconnect. 如果VOIP套接字已断开连接,则在尝试重新连接时必须请求后台执行时间。 But if you are unable to reconnect after the amount of backgrounding time iOS gives you, the app will be terminated. 但是,如果在iOS给您提供一定数量的背景时间后您无法重新连接,则该应用将被终止。

So you should confirm (through tracing or something else) that your VOIP signaling channel is, in fact, alive in the background when you're testing local notifications. 因此,当您测试本地通知时,您应该(通过跟踪或其他方式)确认您的VOIP信号通道实际上在后台还活着。

In conclusion, you have a lot of investigating & troubleshooting to do :) 总之,您需要进行大量调查和故障排除:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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