XMPP framework - a location-based app in the background

I also developed an application that is currently installed as "Location based", so that it can run in the background endlessly. This is not the trick I need to do things when the user moves. After some searching, I found out that this application will execute only the code in case of a change of location, no timer will be able to execute any code in 10 minutes.

My application, while in the background, remains connected to XMPP for 50 minutes or so, then shuts down. I would like the application to never shut down, I looked at the framework, but I can’t find a place to fix this behavior. You know, is it possible to stay in touch "indefinitely"? if so, what settings do I need to change in xmppframework.

thanks

[EDIT] After 50 minutes, the user is still connected to XMPP, but disconnected from the XMPPROOM that was connected. On another launch, it was connected for 3 hours, the iPhone connection time does not seem consistent.

+6
source share
1 answer

For your application to be able to send and receive keep-alive messages, it must be a voip application and use a voip socket. From the documentation for Apple :

  • Add the UIBackgroundModes key to the Info.plist file of your application. Set the value of this key for an array that contains the voip value.
  • Configure one of the application sockets to use VoIP.
  • Before going to the background, call the setKeepAliveTimeout: handler method: the method to set the handler, which will be executed periodically. Your application can use this handler to maintain its service connection.

As for the socket:

NSInputStream and NSOutputStream: for Cocoa streams, use the setProperty: forKey: method to add the NSStreamNetworkServiceType property to the stream. The value of this property must be set to NSStreamNetworkServiceTypeVoIP.

0
source

Source: https://habr.com/ru/post/907841/


All Articles