Even with “voip” present in “UIBackgroundModes” in “plist”, iOS App does not auto start after device reboot in iOS10

前端 未结 2 1798
遥遥无期
遥遥无期 2020-12-31 16:43

I need my VoIP App to auto start after rebooting the device.

Apple docs clearly mention that :-

(=========EDIT: T

相关标签:
2条回答
  • 2020-12-31 17:05

    App will invoke in background when it is in terminated mode only with push kit silent notification and certificates has to be generate for push kit, not with normal APNS notification and normal push notification certificates.

    From back end, your payload has to be like this.

    $body['aps'] = array(
    'content-available'=> 1,
    'alert' => $message,
    'sound' => 'default',
    'badge' => 0,
    );
    

    Once you get pushkit payload, then schedule local notification with sound file, your app will be invoked in background upto your sound file plays.( Max 30 seconds ) Til then you have to complete your background task.

    Kindly do refer some important details about push kit integration step by step process

    https://github.com/hasyapanchasara/PushKit_SilentPushNotification

    Life cycle of app - when app is in terminated and push kit payload comes

    • First of all

      didFinishLaunchingWithOptions // will invoke

    • Then

      didReceiveIncomingPushWithPayload // payload method gets invoke

    • Then if you have local notification

      didReceiveLocalNotification // receive local notification

    • Then

      handleActionWithIdentifier // handler method if you have action buttons ( local )

    • Then if you have remote notification

      didReceiveRemoteNotification // receive remote notification

    • Then

      handleActionWithIdentifier // handler method if you have action buttons ( remote )

    Note - Without tapping on app icon or receiving push kit payload, your app will never gets revoke/open/repoen automatically. If you want your app is VOIP based and app gets revoke after device reboot. Not possible.

    0 讨论(0)
  • 2020-12-31 17:24

    Okay, I investigated this a bit further, but first I should point out I did not verify this by actually trying to build a project for this as it would be too time consuming for me now.

    I found this (already mentioned in the comments), this, and most importantly this tech Q&A.

    What I gathered from especially the various comments of the Apple technicians in those threads, it appears that the behavior of iOS 10 has indeed changed. That means that the same code that connected to VoiP servers in past versions of iOS will no longer do that if you link your build against the latest SDK, i.e. iOS 10 libraries.

    Now, in your case, you don't actually need a real VoiP connection, right? You are just interested in the "start after reboot" functionality, correct? At least the demo project you linked doesn't actually do any VoiP connection, the setKeepAliveTimeout:handler: method, for example, isn't even implemented. I am aware this specific issue is not discussed in the linked threads or addressed in the Q&A, BUT:

    It makes sense that, together with the entire legacy VoiP behavior, the reboot feature vanishes as well. Were you to switch to Push-Kit VoiP, your app wouldn't need to be started after a relaunch, it would restart once the next remote notification arrives (and VoiP notifications have high priority so there's supposedly no delay).

    Obviously I am deducting the rationale behind this entire thing here and can't guarantee Apple really thought along those lines, but it makes sense: The entire reason for a (legacy) VoiP app to be (re-)launched after a reboot was that it needed to make a connection, i.e. it needed to run some code. With push notifications that is no longer necessary (the OS basically does that for you behind the scenes to get those notifications), so it makes sense that they removed this functionality along with the entire legacy VoiP approach altogether.

    You could test this by compiling against the older SDK (i.e. use Xcode 7 as the Q&A suggests) and see whether it relaunches then. That one apple staffer actually explained that the OS does indeed distinguish on the build SDKs for apps, which is totally counter-intuitive to me. Apparently in this case it would decide "hey, this is an older app, so it expects to be relaunched cause its SDK was documented that way" for apps build on Xcode 7 and "Oh, this app is a new one, so I don't need to stick to the old ways" otherwise. Wowsies.


    TL;DR: To me it strongly looks like yes, the iOS SDK changed this behavior along with abandoning the entire old, notification-less VoiP approach. Compiling against the new SDKs will result in apps not being relaunched after reboot.

    For the record: I can understand the angry people in those threads. While there might be technical reasons for the change, this specific consequence was far from obvious. If a method is deprecated, but the project still compiles and runs I wouldn't expect such a process to fail in that manner. Those apps don't crash, they're just "treated differently by the OS", which not quite the same. At least I would have expected the documentation to be clearer about this in the new SDK.

    0 讨论(0)
提交回复
热议问题