I need to implement an iOS app, which needs to receive notifications from the server. The problem is this will run in a LAN without internet connection. So I don't think I'll be able to use Apple push notifications.
And also I don't think I can run a background process to listen to the server continuously (as I understood apple doesn't allow that).
So what is the best way to implement this?
If this is for private usage, because this wouldn't be allowed on the app store, you can run a silent audio track to keep the app alive in the background. Then you can check in with the server and display notification to the user (as local notifications, not push notifications).
For you future / wider distribution, you probably don't want to go with the public app store. Take a look at the B2B options available.
since ios 7 you can use background tasks for downloading and network connections. its now official supported from apple. check out this tutorials:
NSURLSession Tutorial
iOS 7 SDK: Background Transfer Service
Related
I am trying to implement an iOS chat application using Pusher or PubNub (websockets).
Question: How does message delivery work when the iOS app is in the background?
I understand that Websockets implementations provide real-time messaging and don't cache the messages. Is the message lost because the socket connection is broken when the app is in the background?
If yes, how do I recover the lost messages? One idea is to implement a state refresh protocol every time the app comes to foreground.
PubNub Missed Message Recovery Options
You mentioned PubNub (the company I work for) and as #FrankG mentioned, unless you have permission from Apple to run your app in background (staying connected to internet, and therefore, PubNub), you will not receive any message in realtime.
You can use PubNub's Mobile Push Gateway and receive APNS push messages while you app is in background (but idle/not running) or completely not running (kill state).
When the app is activated again, PubNub can be configured to automatically retrieve missed messages from the channel(s) it was subscribed to, but this is good for short periods of disconnection.
For longer periods being offline, you can enable Storage & Playback and use the historyForChannel API to fetch all the missed messages of all channels you require.
Answer: It doesn't.
If the iOS app is in the background, you are out of luck. There is no official (and Apple sanctioned) way of keeping a connection open when the app is in the background. There are hacks like playing a silent audio track to keep it in the foreground, but Apple doesn't approve of such hacks. You'll need to use APNS to send an offline message to bring the app to the foreground so it can reconnect.
And you are 100% correct that the WS standard does not address caching. That has to be performed by another subsystem in your architecture.
The Kaazing Gateway (disclosure: the company I work for) has a feature in our messaging Gateway that caches the last value sent. When the client reconnects (our client libs auto-reconnect), they will see that value.
I want to sync my local DB with server when Push notification came, but I am not able to do it with Silent Notification because application:didReceiveRemoteNotification:fetchCompletionHandler not called when app killed by user. So, I did not know how to do it, then I read about push kit but don't know is it possible to use push kit without VoiP feature. Please tell me is it possible or not??
If not, suggest me any other idea , how will I run background task when app killed by user??
In my experience as well as others on SO - you get rejected for trying to leverage VOIP as a workaround. See below for actual response from apple dealing with a similar attempt.
2.16: Multitasking apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc.
2.16 We found that your app uses a background mode but does not include functionality that requires that mode to run persistently. This behavior is not in compliance with the App Store Review Guidelines.
We noticed your app declares support for VoIP in the UIBackgroundModes key in your Info.plist but does not provide any Voice over IP services.
We recognize that VoIP can provide "keep alive" functionality that many app features would like to use. However, using VoIP in this manner is not the intended purpose of VoIP, which, as indicated in the iOS Application Programming Guide, is that: "A Voice over Internet Protocol (VoIP) application allows the user to make phone calls using an Internet connection instead of the device's cellular service."
Seems that the only way to restart the app when it was killed by user is to use PushKit.
It is possible to use PK framework in your app without Voip functionality, but I can't guarantee you, that your app will not be banned while posting to AppStore.
I am developing an iOS 7+ app and was wondering if there was a way for an app that wasn't running (i.e. not running in the background but completely killed) to start running and perform a function such as a web service call. I am aware of mechanisms such as background fetch and core location being able to send events to an app while in the background (but still running/suspended). Is there such a way to send events to an app that is not running?
I know the answer is probably no, but I need to confirm it.
Unfortunately NO.
Background Fetches will only work after the iOS starts and will stop working once the user force-closes the application. The same is true for Silent Push notifications and Location services.
This SO answer explains the details.
I'm developing an iPhone app which is to make a phone call from my app using VOIP. For that I have to connect with my server every one hour to register my device and make it available for incoming calls at any time. But in iOS7 How is it possible to connect with my server for every one hour even if it is in background mode. Any help would be appreciated.
thanks,
Jirune
There is specific information in the iOS App programming guide on implementing a VoIP app -
To configure a VoIP app, you must do the following:
Enable support for Voice over IP from the Background modes section of
the Capabilities tab in your Xcode project. (You can also enable this
support by including the UIBackgroundModes key with the voip value in
your app’s Info.plist file.)
Configure one of the app’s sockets for
VoIP usage.
Before moving to the background, call the
setKeepAliveTimeout:handler: method to install a handler to be
executed periodically. Your app can use this handler to maintain its
service connection.
Configure your audio session to handle transitions
to and from active use.
Once your socket is configured for VoIP usage, iOS will manage it for you in the background, keeping it alive and notifying your app when there is traffic
The iOS app i developed uses APNS. Locally i could simulate the whole process from saving device tokens, sending push notifications to deleting device tokens with help from APNS feedback successfully. Also in production it worked for a short time.
Now my webhoster closed port 2196. Port 2195 is available, so sending notifications is still possible. I do not want my ios app to get on the blacklist, so is there any other way to register whether a user has deleted my app on their device? Or will i have to look around for another webhoster, who has both ports open? Any suggestions?
You'll have to look for another host or look into 3rd party solutions that have a Feedback API. I know Urban Airship had one (haven't used it in a while) and may be giving access to it freely.