2013-02-28 4 views
0

나는 voip 응용 프로그램에서 작업하고 있는데, 응용 프로그램이 백그라운드로 진행될 때도 항상 서버와의 연결을 유지해야하며, 사과는 통신 소켓을 사용하도록 지원합니다. 내 문제는 별도의 서버 (예 : 로그인 서버 고려)입니다. 매 1 분마다 서버를 보내려면 백그라운드에서 응용 프로그램을 실행하는 두 개의 통신 소켓을 가질 수 없다고 생각합니다. 이 경우 어떻게해야합니까?백그라운드에서 응용 프로그램을 보낼 때 살아있는 패킷을 보내는 방법 - IOS?

applicationDidEnterBackground에서 스레드를 분리 했으므로 일시 중단도됩니다. 내 문제의 해결책은 무엇입니까? 어떤 생각?

답변

1

응용 프로그램이 항상 ios에서 실행되지 않습니다. 푸시 알림에서 도움을 받아야합니다. 하나의 소켓을 사용한다고 할지라도 미리 정의 된 시간 이상 실행될 것이라고 생각하지 않습니다. 모든 VoIP 앱은 푸시 알림을받습니다.

Refer this link

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. 

참고 : 수신기가 알림을 밀어 응답하는 경우 하나의 MSG를 보내 무효 응용 프로그램의 대부분 사용자처럼 작동 서버가 수신기 푸시 알림을 보냅니다, MSG가 처리됩니다. 트위스트는 사용자가 푸시 알림에 응답하지 않을 때 발생합니다. 앱이 시작되면 처리됩니다. 사용자 앱은 모든 서버에 대해 서버를 쿼리하고 그 메시지를 앱 인터페이스에 표시합니다. 희망이 논리는 당신을 도와줍니다.

+0

시간 내 주셔서 감사합니다. 푸시 알림을 확인합니다 ... 한 가지 더 궁금한 점이 있습니다 ...이 API setKeepAliveTimeout이 도움이 될까요? 600 초마다 다시 시작하고 사용할 수 있습니까? – Newbee

+0

-setKeepAliveTimeout : handler :를 호출하면 모든 작업을 완료하고 일시 중단하는 데 최대 30 초 밖에 걸리지 않습니다. 응용 프로그램을 처음 백그라운드로 전환 할 때 부여되는 것과 동일한 백그라운드 유예 기간이 주어지지 않습니다. 그것은 장기간에 걸친 작업을 마무리하기위한 것입니다. – DivineDesert

+0

짧은 말로하면 도움이되지 않습니다 – DivineDesert

1

당신이 제안하는 것은 극도로 배터리 집약적 인 것입니다 (라디오는 유휴 상태가 될 수 없습니다). 앱 스토어 앱에서는 허용되지 않습니다.

푸시 알림을 통해 서버에서 정보를 가져와야합니다.

+0

답장을 보내 주셔서 감사합니다. 모든 VoIP 앱이 동일하게 적용되고 있습니까? 다른 방법은 없습니까? – Newbee

+0

그것이 당신이 제안한대로 작동한다면 그것은 승인되지 않을 것입니다. 전화는 거의 지속적으로 높은 전력으로 작동합니다. – StilesCrisis