Testing VoIP push messages - messages only arrive in-app - ios

I have a very simple PHP test script that initially works, using the following server config:
$domain = "gateway.sandbox.push.apple.com";
$url = 'ssl://' . $domain . ':2195';
I'm receiving PushKit notifications every time I expect them including when the phone is locked. However testing it over and over while trying to implement the server side and convert it to HTTP/2, it just stops working reliably and only seems to trigger when I'm inside the application.
Inside the application: always works
Outside of the application including just backgrounded the app: works in the beginning, then stops working
It's very hard to get it to work if I don't know if even the most basic form of sending the message (through the PHP test script works). Also it worries me that my production application might suffer from the same kind of throttling if a user is sending too many messages (i.e. mom trying to call from the hospital 10x in a row).
I do always trigger CallKit in my PushKit code path every time so I think I'm good regarding to the changes in VoIP pushes in iOS 13.
What could be the cause of this different over time? How (if possible) can I prevent it? How can I detect it?

For that one person that upvoted my question but didn’t find a response:
Killing the app makes the OS think depriotitize it and it leads to the OS not forwarding the VoIP push anymore. To mitigate this problem as a developer you need to start the debugger without launching the app, so when you open the app from the push it can attach. Then kill the app only through the stop button in Xcode.
Testers need to be instructed about this problem. If you’re sure the code works for you and it stops working for the tester, they need to uninstall the app, restart the phone and install it again. If possible never kill the app manually. This sucks, I know it.

Related

General questions about Restcomm SDK for iOS

I am starting an application using Restroom and have a few questions about the iOS SDK.
I read through the documentation here http://documentation.telestax.com/restcomm-ios-sdk/doc/html/Classes/RCDevice.html#//api/name/listen
I have also checked out this:
https://github.com/RestComm/restcomm-ios-sdk
I see that the RCDevice class has a listen method and an unlisten method. If I want the device to always be available to receive calls should I have the listen method always going? If so, is this going to be terrible for battery life?
How do I make sure that the application is always running on the device so that it can always receive calls? I am pretty sure that iOS 10 will stop background connections unless the app is running in the foreground.
Is there a way to wake the application or open the application in the case of an incoming call? Can I use push notifications or something similar to wake/open the app?
I already replied to this question on the Restcomm Forum, but let me also answer here for better visibility by the community:
Yes, once you call unlisten() you will no longer be registered and hence receive no incoming events.
Ok, so it varies per platform. For Android since the SDK is wrapped in an Android Service even when the App leaves the foreground, the SDK continues running and you are able to receive events (we still need to check some updates on Android O though on that respect). For iOS we haven't implemented that yet so once you leave the foreground you are not able to receive any events :(. However, the plan is to move to Push Notifications functionality on both platforms soon.
Please check (2). Also, without Push Notifications, we were planning of supporting this with https://github.com/RestComm/restcomm-ios-sdk/issues/153, but also this isn't ready yet.
Best regards,
Antonis Tsakiridis

How to update app when new data is available

I'm fairly new to app development and am having trouble figuring this out. One part of my app involves a messaging platform. Right now I am using a php web server to connect to MySQL backend. I have all the functionality of a messaging app, but I am unsure how to push new messages when they are available.
One basic solution would be to call my function to check for new messages every x amount of seconds, but obviously that's not a good solution. I have looked into Apple Push Notification Service and am unsure if this would fit my needs. When I looked into it this seems to be for sending notifications to the user remotely. However, rather than the user getting these messages displayed I would like the app to call a function instead (the function would load the new messages). Is this possible with push notifications?
Also this app is on both iOS and Android, so if there is a (possibly third party) solution that would cover both it would be ideal.
Any insight into this problem is greatly appreciated!
When you send a push notification and the app is in the foreground, the AppDelegate has a method called which allows you to execute whatever method you want.
This is only for iOS though, I don't know know it's handled in Android.

swift 2 iOS 9 - Task running after app destruction: how do it?

I'm newbie in iOS App world so pardon me if my questions are simple and banals
I have this scenario:
my server side generates MQTT messages on a well known topic
my app can connect to the MQTT Topic and can receive messages
All works pretty good; what I would like to do now is the following (if possible)
When the user stops the app (by deleting it from the task manager) I'd like to have a kind of service able in being connected (or remaining connected) to the MQTT Topic; in this way also when the app is no more running I can receive MQTT messages
Basically I'd love to have something similar to Facebook messenger that is able in receiving messages also when the app is not running
NOTE: i can't use remote notification mechanism provide by Apple
Remote notifications would be perfect for this, shame that it's not an option for you.
There are a few other situations where apps can run periodically on the background, they are described here:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
BUT, from that page: "In most cases, the system does not relaunch apps after they are force quit by the user."
So in general an app will run in background only if the user exits it normally, not if he forces it to quit in the task manager.

Chat app synchronization on background in IOS

I have a chat application developed by JS. I want to send PING to server once in a while. Its not a problem if app runs on fore ground. The problem is when user minimizes it or open another app. My app looses its focus and gets into suspended state.
I have following two use-cases.
To keep the chat session open I need to send PING to server (Its an IRC server) every X minutes even the app runs in background.
We also need to check for new messages (by ajax on a local http server) and add a local notification to the notification queue so when user clicks on it app can resume
I have found apple does not allow running apps in the background. if they allow they require special permission. I found some apps does it by requesting finite length execution time.
What is the best way to get highest possible background execution time? As a chat app can I request permission for voip, location or any other way ?
Note: the app will be running in an environment where there is no Internet. Hence push notification will not work here.
Update: After doing a lot searching I found background fetch. It seem background fetch will suite it. But still the problem remains, its not called in a timely manner.
This sounds like an interesting problem. From reading the various comments, it sounds like you want this to work when you're on a local network - so you have wifi, but the wifi router/base station isn't connected to the actual internet?
Because background refresh isn't going to be predictable - you'll never know when it is going to update - you might want to get creative.
You could look into exploiting iOS VOIP support, only without the Voice! Apple has some tips on VOIP here. VOIP basically uses something called SIP (Session Initiation Protocol), which is signalling layer of the call, and a lot like HTTP. It's this SIP layer that you want to take advantage of.
This isn't going to be terribly easy, but it should be achievable. Setup your app to use VOIP, and then look into something like PJSip as your SIP library. Then, on your local network have a SIP Server (I'm sure there are plenty open source implementations) that you can register your iPhone against (so your server knows where your phone is, pretending to be a VOIP phone). This should work, because it doesn't need to go through Apple as far as I am aware... And will run happily on your local network.
Then, the server can send a message via SIP to the handset, as if it were instigating a VOIP session. You app is awoken, gets the messages - ideally from the SIP message if possible - and then just doesn't start the session. SIP was designed just for creating sessions, not just VOIP. When I worked in Telecoms R&D (a long time ago) we were using it to swap between Text/Voice/Video, all using local servers.
You'll have to jump a lot of hoops to make this work, but it would be pretty awesome. I have never tried this actual use case - especially with iOS, but I'm fairly sure it will work. It is a bit of a fudge, but should get you where you need to go.
Good luck!
You can use something like PubNub to build this chat app with iOS using native Objective-C code, or with the Phonegap (Cordova) libs.
The beauty with using a real-time messaging network like PubNub is that when the app goes to the background, you can easily have the chat messages come in on APNS.
When the app is in the foreground, it can just receive them as the native (PubNub) message. And if it needs to "catch-up" with the messages it missed while in the background (but received via APNS), its trivial to implement.
Also, PubNub is platform agnostic -- so you can easily also use it on Web, Android, BB, Windows Phone, etc.
http://www.pubnub.com/blog/build-real-time-chat-10-lines-code/
http://www.pubnub.com/blog/html5-websockets-beautiful-real-time-chat-on-mobile-using-pubnubs-channel-presence/
https://github.com/pubnub/objective-c/tree/master/iOS
https://github.com/pubnub/javascript/tree/master/phonegap
geremy

How can I determine if an iOS device has come back into Network coverage if the user has closed the app?

We are building an enterprise class Work Order application where the users will often be in areas with no network coverage. We want to be sure that when they come back into coverage, any work that they have done on locally stored work orders is sent back to the server ASAP. This is easy to do if the user keeps the app running, but in our situation it is very likely that they will switch between apps, and the Work Order app may not be running when they come back into coverage.
We have thought of having the app fire an email to a server side listener when it senses that it is out of coverage. When the device comes back into coverage, the email should get delivered, and the server can send a push notification to the user to open the app. This feels like a bit of a hack... is there a better way to handle this situation?
As you already noticed, push notifications is the way to go, but even with them its not guaranteed that the user will send the data or even open the app.
I would suggest that you make the data itself expire after a limited time and alert the users when they minimize or even close the application.
You can also use local notification to alert about expiration.
So long as this is an enterprise application that doesn't have to be distributed through the App Store, you can abuse the audio background processing mode to keep your application running at all times. All you have to do is play a silent audio file on a loop as if you were a media player. This will keep your application running in the background, where you can retry connections to the server as you'd like.

Resources