I'm building a voip app for iOS and I'm handling working at background.
So far, i have iOS listening to the voip socket while app sleeps and wake it uppon incoming data.
My question is:
When the reachability has changed (Wifi -> 3G, Wifi -> Other Wifi, etc)
and the app is suspended, can I get some notification in order to reconnect my voip socket?
Thanks.
Answer was both Yes and No:
Register to Reachability network changes notifications.
If App goes to background suspended while its voip socket (see link) is connected, then uppon network changes app will wake up at background for 10 seconds.
If App goes to background suspended while its voip socket is NOT connected, then uppon network changes app will NOT wake up.
The solution for the scenario of network loss and going to background with no connection may be fixing the connection in the Keep-Alive block that you can schedule at UIApplication.
Note: during the mentioned 10 sec, you may ask for a background task in order to finish the reconnection job.
Links:
VoIP socket in iOS
VoIP socket wakeups - iOS 5 Watchdog
If you have a backgrounding socket you can subscribe to reachability notifications and they will fire while backgrounded so you can perform actions on the reachability changes. If you don't unsubscribe to the notifications when you hit the background you'll still get them if the object subscribing to the notifications is your app delegate.
Related
I'm having a problem with react native
my app can let you video call each other using webRTC and socket.io, the technologies i use are WebRTC, React Native, Socket.io , socket.io-client, react-native-webrtc
Basically the way my app works is when you open the app you automatically connect to socket.io to listen and make calls but when I turn off the phone screen or exit the app I can't hear and receive calls can call again because at that time the socket has automatically disconnected.
I want my application can still work properly even if I exit the application my application can still receive notifications of incoming calls from another person, can say I want my application Works like Messenger App
My current workaround is to find a way for each user's socket to always be connected to listen for incoming calls from others.
Has anyone encountered this problem or have a solution for this please let me know, I really appreciate it
Thank you guys, Have a nice day <3
Move your socket to the Background service and then you can add the socket events in the service.
Note: This will increase your battery consumption.
I built a VoIP calling app which maintains a persistent connection with the server to listen to any incoming calls. I implemented a background service to do this.
But since Oreo, this running code is now broken because of the introduction of Background Execution Limits
After looking into forums, I found that some people are suggesting
Convert Service to JobService and let android schedule it
Doing so, my app won't be able to receive calls when it is stopped
Run your operations in foreground services
It is annoying for some users to see a constant notification in the notification bar. So these above-mentioned options aren't working for me to fix my code for Oreo.
How does WhatsApp get the incoming (VOIP) call in Android (Oreo onwards) working around the Background Execution Limits?
(Sticky) foreground services are not affected by the restrictions. So you could use one those as replacement for background services on Oreo.
But foreground services have two disadvantages: They are less likely killed by the system in order to reclaim resources compared to background services, and hence affects the Android system's self-healing capability. And they require you to display a permanent notification. But Users are able to suppress the notification, somewhat mitigating this disadvantage.
I am assuming that you are using SIP to establish the connection and initiate calls. Without a service constantly re-sending REGISTERs, the app doesn't receive INVITEs when the server sends them.
A workaround for this problem is what is called the "push notification strategy". It works as follows, when the server sends a INVITE, it also sends an FCM notification to your app, This wakes up your app which then sends a REGISTER to your server, which in return forks the call to your app. Here is a video that better explains this strategy
There are two options:
use platform push services (APNS or FCM)
maintain persistent socket connection and exclude application from battery optimisations.
Inside WLClient.h mention this comment.
#note The client sends a heartbeat signal to the server only when
the application is in the foreground. When the application is sent to
the background, the client stops sending heartbeat signals. The client
resumes sending heartbeat signals when the application is brought to
the foreground again.
I set my setHeartBeatInterval to 420. which is default. But when the app goes into background with lock screen. It still will call the heartbeat after 420 seconds. Then my app crash.
Is there anyway to disable the heartbeat call when the app goes into background?
Thanks so much =)
On MFP 7.1, we are not seeing any issue with heartbeat in both iOS 9.3.5 and iOS 10. In both iOS versions, when the app is in background(by pressing home or behind the lock screen), the heartbeats are paused and are not sent.
We see this behavior in the latest v7.1 iFix version and on iOS devices running iOS9.3.5 and iOS10.
However, on iOS10 simulator, we can see couple of heartbeat requests are made when the screen is locked or if the home button is pressed. But, even here, when the app is resumed, there is no crash. This seems to be a behavior with iOS 10 simulator only.
If my device don't have internet connection and I have send 100 Push message to my device then how many message I will received after the connection comes online and What is maximum limit of apple push notification if device have no internet connection?
If APNs attempts to deliver a notification but the device is offline, the notification is stored for a limited period of time, and delivered to the device when it becomes available.
Only one recent notification for a particular app is stored. If multiple notifications are sent while the device is offline, each new notification causes the prior notification to be discarded. This behavior of keeping only the newest notification is referred to as coalescing notifications.
For more detail, read Quality of Service of Local and Remote Notification Programming Guide
I am developing chat application using XMPP protocol.
My development target is iOS 7.0
Every think is working fine user can able to communicate only when they are online.
But I want to notify user message has come when they are offline.
I have tried iphone XMPP App run background
But it doesn’t work for me.
First think it is possible or not?
Using what VIOP, background fetch or some other way?
If yes please let me know. how?.
The thread you are referring mention declaring that your app is a VoIP app to be allowed to constantly run in background.
It is technically possible but has two drawbacks:
If your application does not do voip, Apple will reject it (as misleading).
Battery consumption will be excessive as you will stay connected.
The state of the art is to fallback to Apple push notification service when the TCP connection between the client and the server is not established. This is battery efficient and provide a very good way to notify the user of new messages.