繁体   English   中英

在后台应用程序时如何发送活动包 - IOS?

[英]How to send alive packet when application in background - IOS?

我正在开发一个voip应用程序,我需要始终保持与服务器的连接,即使应用程序运行后,苹果提供支持使用通信套接字,我的问题是我有一个单独的服务器(即考虑登录服务器)我想发送每隔1分钟对该服务器执行一次确认,我想我不能在后台运行应用程序的两个通信套接字。 在那种情况下,我如何发送确认?

我已经从applicationDidEnterBackground分离了一个线程,它也将暂停,我的问题的解决方案是什么? 任何想法?

你所建议的将是非常耗电的(收音机永远不会有空闲的机会)。 这在App Store应用程序中是不允许的。

您需要通过推送通知从服务器获取信息。

您的应用程序永远不会始终在ios中运行。 你需要从推送通知中获取帮助。 即使您使用一个插槽,我也不认为它会运行超过预定义的时间。 所有voip app都跟随推送通知。

请参阅此链接

    Declaring Your App’s Supported Background Tasks

    Support for some types of background execution must be declared in advance by the app that uses them. An app declares support for a service using its Info.plist file. Add the UIBackgroundModes key to your Info.plist file and set its value to an array containing one or more of the following strings:
 - audio—The app plays audible content to the user while in the
   background. (This content includes streaming audio or video content
   using AirPlay.)
 - location—The app keeps users informed of their location, even while
   it is running in the background.
 - voip—The app provides the ability for the user to make phone calls
   using an Internet connection.
 - newsstand-content—The app is a Newsstand app that downloads and
   processes magazine or newspaper content in the background.
 - external-accessory—The app works with a hardware accessory that needs
   to deliver updates on a regular schedule through the External
   Accessory framework.
 - bluetooth-central—The app works with a Bluetooth accessory that needs
   to deliver updates on a regular schedule through the Core Bluetooth
   framework.
 - bluetooth-peripheral—The app supports Bluetooth communication in
   peripheral mode through the Core Bluetooth framework.

    Each of the preceding values lets the system know that your app should be woken up at appropriate times to respond to relevant events. For example, an app that begins playing music and then moves to the background still needs execution time to fill the audio output buffers. Including the audio key tells the system frameworks that they should continue playing and make the necessary callbacks to the app at appropriate intervals. If the app does not include this key, any audio being played by the app stops when the app moves to the background. 

注意:大多数虚拟应用程序的工作方式类似于用户发送一个消息,服务器向接收方发送推送通知,如果接收方响应推送通知,则处理消息。 当用户不响应推送通知时,Twist会出现。 这是在启动应用程序时处理的,用户应用程序在服务器中查询任何消息,然后在应用程序界面中显示消息。 希望这个逻辑可以帮到你。

暂无
暂无

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

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