ios 7 fetch offline message from xmpp server - ios7

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.

Related

How to always connect to socket.io even when shutdown or exit the application to be able to receive notifications from calls or messages(React Native)

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.

How does apps like Whatsapp or telegram listen to the incoming call/message events on Android?

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.

Does startAdvertisingPeer work when app enters background?

I'd like the app to advertise a service even when the app enters the background. With Core Bluetooth, this is possible by setting bluetooth-peripheral for UIBackgroundModes.
Does anyone know if the same can be achieved with MCNearbyServiceAdvertiser? Thanks.
When I was at WWDC this year I went to a Developer Lab for Multipeer Connectivity and was told by an Apple engineer that no, service advertisers and browsers will not work in the background.
That said, I've been successfully communicating with connected peers with an app running in the background using a background task, but I have not been able to advertise or browse.

iOS Inter App Communication in Background

There is a platform application which connects to the remote server and stores required information in its local repository, that is in CoreData. I want to develop my application over this platform app. Since it is not possible to access its local storage, I have to communicate with it somehow. I am able to send/receive data using URL Schemes; however it's frustrating for user to switch between apps constantly.
Is it possible to communicate with another application via URL Schemes (or any other way) without bringing it to foreground?
With few exceptions, such as receiving CoreLocation data in the background or being notified to wake up by a local notification, it is not possible in iOS for an application to "run in the background"
This is a pretty common query on Stack Overflow, the official iOS reply can be found here
There are SO articles here and here.
Background data exchange is however not going to be a thing as there are restrictions on background app rules (so the URL transfer is going to foreground your second app)

C2DM Behavior over Wifi and 3G

I'm developing an app which relies on C2DM to be notified of some new data to be fetched from a REST service. I have successfully implemented the C2DM android feature, but the behavior over Wifi is different from the connection over 3G. The messages are received instantly over 3G, but I have to manually turn Wifi off and on to have a "grace period" of ~1 min in which I receive them instantly.
My question is: Is there any way I can programmatically restart the connection, or trigger the notification fetch?
EDIT:
I've implemented an AsyncTask that periodically "reassociates" the connection to the access point (using WifiManager.reassociate()) every minute and a half. Not so sure about the correctness of this solution, though.
I've seen similar issues. It seems that under some circumstances C2DM messages are not delivered over wifi connections, when they are over 3G. On a related note I've also seen Android devices "drop" the push connection, so messages are not delivered (in my case the solution can be to put the device in airplane mode and then turn the network back on).
This reinforces the fact that all applications that use C2DM should be built so that even if push messaging fails, the app still works (even if messages/updates are slower because there's occasional polling to the server)
I wouldn't personally want to mess with the wifi connection as that's something that may cause problems for the user.