App not receiving VOIP after x time on iOS 10.3 > - ios

I've got a project I'm working on which uses VOIP notifications to "wake up" apps that have been put into background/terminated. These notifications are sent periodically, and everything seemed to work fine until recent iOS updates.
It appears that after a certain amount of time in which the app has been in the background (happens to some users after 5 minutes, others after 20), the devices no longer process any code after receiving the voip notifications.
I've read a bit in apple dev forums and some other devs are running into similar issues, all speculate if its related to the new iOS updates (10.3.1/10.3.2).
Has anyone else run into this issue, and if so, have you been able to solve it?
Thanks!

This is the new normal on latest iOS versions.
You should begin to use push notifications.
Here is a guide from Apple.

What ended up seeming to be the fix was updating to a newer version of socketio library.

You can try debugging your app in background or in kill state ( terminated state ), so you can get to know that payload from pushkit comes or not or possibly some crash at iOS code end.
Debug pushkit notification in terminated state
Put debug pointer on delegate methods
Go to edit scheme
Select run option then Launch -> Wait for executable to be launched
Send push kit payload from back end
Once you get payload on device
it will automatically invoke and debug pointer will invoke at delegate methods.
Refer

Related

iOS Push Notification Programming - Is there a way to disable push notification on iPhone by programming

A few days ago, I got the issue below.
I've been getting notifications for the past several days. The notification had been enabled, and the app was working (I received push notification) until it suddenly didn't yesterday. And when I open the app, it suddenly asks me to enable notification (please see the picture "iOS Push Notification Permission Alert.png")
iOS Push Notification Permission Alert.png
I guessed that my client removed the app and re-installed, so all permissions were lost. But they said that they didn't.
So, How can it happen?
My concerns are:
If notification was enabled, how can it show the alert above again? Is there a possible way?
If notification was not enabled, why have I received the notification for the past several days?
Under which scenario(s), would an app suddenly disable already enabled notification? Is there a way to disable notification permission for the app on the iOS phone by programming?
I will appreciate your answers so much!
P/s: I read the post disable push notification in app, but it doesn't help for my questions.
This is only possible if the app is reinstalled or the notifications are turned off from the settings.
There is one setting in iPhone which will allow iPhone to offload the unused apps and if this happened, there will be a cloud icon on the left of app title.The app will be reinstalled when you click it again.
And it seems that it will also happened when the storage of iPhone is not enough.
So I guess this happened in your client's phone.
This setting is in both Setting-iTunes & App Stores-Offload Unused Apps and Setting-General-iPhone Storage-Offload Unused Apps.

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

I need my VoIP App to auto start after rebooting the device.
Apple docs clearly mention that :-
(=========EDIT: This is from official Apple docs please have a look at this before commenting or answering that the App cannot be launched without user interaction or silent push notification. Also have a look at Github project below, people have verified this behaviour)
Values for the UIBackgroundModes array
Value : voip Description : The app provides Voice-over-IP services.
Apps with this key are automatically launched after system boot so
that the app can reestablish VoIP services. Apps with this key are
also allowed to play background audio.
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW1
I have ensured that :-
The App was running when the device was powered off.
VoIP is present in the plist and Capabilities section.
Ensured that app the certainly not launched after device reboot by adding logs to a file in the main method and the application:didFinishLaunchingWithOptions: method.
Screen of the device is unlocked at least once, after the device has been rebooted.
I even tried executing this GitHub example App with 36 stars to test
Boot Launch. https://github.com/lithium3141/BootLaunch
But even this App does not restart on reboot when I tried on device.
Hence, this leads me to think if something has been changed recently in iOS10 or am I still missing something here?
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.
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.

iOS 10 push notification authorization request showing up on app launch

Previously, when building my app using the iOS 9 SDK, the push notification authorization request alert (that system alert which says: "App" Would Like to Send You Notifications ... Don't Allow / Allow) would only show when I called [[UIApplication sharedApplication] registerForRemoteNotifications].
We've decided to actually only do that at a certain point in the game, so the user is only encouraged to allow push notifications when it makes sense.
On iOS 10, I understand we must use the User Notifications framework to accomplish that (by calling requestAuthorizationWithOptions:completionHandler: on [UNUserNotificationCenter currentNotificationCenter]), enable Push Notification on the app Capabilities and setup the entitlements. And that does work on some devices, but not all of them.
On some devices, the authorization request is presented to the user right at app launch even though I did not call requestAuthorizationWithOptions:completionHandler: or registerForRemoteNotifications at any point yet.
The weirdest part is that this happens consistently on some devices (running iOS 10.1.1 or 10.2 beta), even if I install the AppStore version of the app (which was built using Xcode 7 and iOS 9 SDK).
Should I assume this is a bug of iOS 10? I couldn't find other people with the same issue, only a kinda similar issue here.
The issue is actually a change from iOS 9 to iOS 10 on Game Center's [GKLocalPlayer localPlayer].authenticateHandler.
When it is set, it will trigger a push notification permission request on iOS 10. This did not happen on iOS 9.
For anyone stumbling upon this and not finding the above answer to have been the cause of their problem, it should be noted that attempting to change the app badge will also result in a Push Notification request.
My personal situation was regarding a Cordova app, where I was loading and applying the badge plugin before initialising push, and couldn't work out why the Notification permission dialog was appearing on app launch.

IOS9 Push notifications dialog appears after delete and launch app with xCode7

I have an application, it uses APNS, so I have code that subscribes to notifications, and everything works fine. But every time I reinstall app, and run it with xcode, I get allow push notification dialog. Every time.
I found hundreds questions about how to achieve this dialog again, but none - how to stop achieving them. I need help!
It's seems known IOS9 bug, here is a link for developer forum and still no response from apple and no solution:

IOS push notification break point

I use phone-gap plugin for APN and xcode 5.
https://github.com/phonegap-build/PushPlugin
I put a breakpoint at each function in the plugin.
For some reason when i send a push notification not even single break point are hit.
But the notification received on my device.
Any explanation for this.
Thanks in advance.
There are some things you could check:
Did you set them in in xcode or in the safari debugger? Actually I am not sure if the first option would ever work at all. Have any breakpoints worked in your application?
Is the app running in the foreground when the notification is received? As far as I know, no code is executed on receiving the message if the app is running in the background, so this might also be a reason for not hitting any breakpoints.

Resources