How to keep XMPP connection alive in the IOS App when app in background? - ios

I have create basic chat app with XMPP Server in swift 2 (from this tutorial: http://shubhank101.github.io/iOSAndroidChaosOverFlow/2016/08/Chat-Application-Using-XMPP-Swift-Tutorial). My app is working good. but when my app went into background then my app unable to receive any message from XMPP server. i think this is because of XMPP connection break while entering the app in background.
i have tried to found the help on google for the same but nothing found related to Swift 2
Please help me. if some one put some sample code that would very helpfull for me because i m new to IOS development.

Third-party apps on the iOS are not allowed to keep network connection in background. See Apple guidelines how to avoid background networking.

You need to create a background thread to maintain XMPP connection. You can follow this tutorial to see how background thread works. https://thatthinginswift.com/background-threads/

Related

VoIP and Callkit framework audio issue

I am using VoIP Push and Callkit Framework for audio and video call feature in my app. I am able to display incoming call screen when app is in background mode.
I am facing one issue, that is when I answer the call, I am hearing my own voice again from device speaker.So please help me to resolve this issue.
I checked with the Speakerbox sample app given by apple developer, It that also same thing happening.
Thanks in advance.
The issue could be the setup of the IOUnit in AudioController.mm.
Check my answer here: https://stackoverflow.com/a/42034409/3990192

watchOS Show App When Message Received [duplicate]

I know that an apple watch app can launch its parent application in the background to pass data back and forth but can it work the other way around? Can my iOS app launch the related watchOS app?
For a bit more insight, I'm trying to accomplish this so that I can monitor data periodically for the sake of notifications. The 70 seconds apple gives me to keep an app active and pulling data from healthKit isn't conducive to an app that provides alerts to users based on changes in behavior.
I apologize if this is a basic question. I'm new to watchOS development and haven't been able to find the answer to this anywhere. =/
No it cannot happen.
At the moment communication between the Watch and the Device is limited to the Watch App initialising communication with the iOS app and not the other way around.
This might help:
https://developer.apple.com/library//ios/documentation/General/Conceptual/WatchKitProgrammingGuide/SharingData.html#//apple_ref/doc/uid/TP40014969-CH29-SW1
Yes, you can. Try the startWatchApp(with:completion:) func in HealthStore. However, it can only be used in a workout app that enable the background mode of "workout processing".
Unfortunately I think I found the answer here How to programmatically open Apple Watch companion app from iOS app.
It doesn't look like it can be done. If anyone finds otherwise, let me know!

Sinch notifications don't show up when app is not open

I am developing an ios app using Sinch with swift and notifications are showing when the app is working in background but when I close the app, notifications won't show up. All resources in Sinch docs are in Obj-c that's why I am asking this question in here. Is there anybody worked with Sinch using swift and can explain to me little bit.
Its actually not a swift thing at all, it applies to objective c as well :D
When you open the app and you have pushed a notification (or not) you will receive a regular on message recieved to you MessageClient delegate, when you get that and are not in the chat screen you need to decide what you want to do, either show in in app notification or take the user to that screen (I suggest showing an in app notification)

RUNNING socket.IO-objc IN background

I am working in iOS app Development .I am using
pkyeck/socket.IO-objc in my app to implement scoket connection. My Socket connections working well while the app running in foreground.but if my app goes to background the socket connections are stopped to work. please tell any suitable solutions to run app in background too. Thanks
This is in the project capabilities, it is called "Background mode" iirc. Here is a tutorial describing more details.
Basically, I suppose you want the "fetch" background mode.
https://www.captechconsulting.com/blogs/ios-7-tutorial-series-whats-new-in-background-multitasking

What's solution to make task background in iOS same service in Android?

I'm newbie iOS. I have been develop Phonegap for Android and iOS. My App is update data from server every 1hour. In Android, i use service to do that. My app in Android working very good. Now, i want to develop version for iOS, and i have problem when update data from server every 1hour. I was research but not find anyway for my app.I don't know what's solution to replace for service in Android. Can you help me, what's solution. This have been kill me. Thank you so much.
Short answer is NO as Apple has restriction on background task running especially cases like yours.
But if you are downloading small amount of content, you do have some other options. From IOS 4.0 or above, you can declare your app to run in background when you fall under the following categories:
Audio
Location updates
Voice over IP
Newsstand downloads
External accessory communication
Bluetooth networking
Bluetooth data sharing
Background fetch (IOS 7)
Remote notifications (IOS 7)
In order to do so, you need to flag your app in the info.plist for Required Background Modes option. Apple will review your app specific in this area once you declared the option.
For your case to download the data, the possible option is to use the new feature in IOS 7 that's the background fetch or remote notification above. The suggestion from DOM was not asking you to download the content through push notification. But instead to use push notification to wake up your application and start downloading new content.
If you don't want to use push notification, the only way to go is register for background fetch. However, no matter which option you want to use, each download will only last for 30 seconds. And after that, your app will put into suspension mode again.
you can have a look on the link here:
Declaring Your App’s Supported Background Tasks
I think your best bet would be to use the push services instead of having your app go get data. Making your app do it is unreliable with phonegap apps because you cant create a service interface and you can not guarantee that your app will be running. With push service though, if your app isn't running, it will be woken up in a manner of speaking.
Take a look at this great how-to article that also discusses what push provides you.

Resources