iOS - i need processing time after silent push - ios

My app makes use of push notifications to alert the user when they receive a message. Due to the nature of my server and also due to encryption, the server does not know what the message is, only the iPhone is able to decrypt it. However, i would like the message to show in the notification. So i need processing time after a silent push to download and decrypt the message then use a local notification to tell the user
However, iOS doesn't allow processing time for killed apps, only for foreground ones or ones still in the app switcher. How can i workaround this issue?
One solution i have found is PushKit. This seems to relaunch apps even if they've been force quit. However, it only does this for VoIP apps, my app is not a VoIP app and I think App Review will reject it if I use PushKit

It is exactly as you described it and there is nothing to add. If the app is killed, you have no way of processing a silent push notification other than PushKit, but if you use PushKit, your app won't go through the review if it doesn't implement VoIP.
Your best option is to send push notification with a generic text (e.g. "You have a new message") instead of a silent push notification, that will serve as a fallback for the case that the app was killed. If the app was not killed, you can discard/remove the remote notification, download and decrypt the message and show a local notification with the actual message. If the app was killed, the remote notification with the generic text will be shown instead and the user will at least be notified that there is a new message.
Add this behavior to the FAQ of your app to encourage users to not kill the app. There is no reason to do this on iOS anyways, so if a user kills an app, he shouldn't expect that it works as desired.
Addition on misusing PushKit for this:
If you misuse a functionality/service for something it is not intended to be used for, your app will probably be rejected. So if you enable VoIP background mode, but your app doesn't provide any VoIP functionality, it is pretty obvious.
From the App Store Review Guidelines:
2.16 Multitasking Apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion,
local notifications, etc.

Related

iOS silent push notification

I am trying to implement silent push notification in my application where I need to update some data in the server when silent notification comes. I am using Pushkit and it uses VoIP certificate for silent push notification but the app has been rejectd by Apple saying that "I can't use VoIP" certificate. It seems that apple has rejected it as I don't have any VoIP call functionality in my app. In that case how can I implement silent push notification so that my app gets activated even if it is not runnning(not even in the background) and I can update the server?
From my experience, iOS respects user's choice, so in case the user has killed the app, it will remain killed - no silent push notification will wake this app. VoIP is an exception to that, but as you wrote, it should be used only in VoIP apps. This makes sense, consider it a platform limitation: thanks to that user have some control over what is actually running on the phone, the device consumes less battery and lastly, foreground/system Apps has the most CPU time to utilize.
There are few techniques to work with data in the background:
Content-available push notification: will wake up the application in case it is suspended, or startup it in case it has been killed by the system/crashed. Note, that this only opens a 30-second window and amount of notifications is throttled by APNS.
Background fetch capability will act in a similar manner.
Background task to finish existing task - but this is only used when app is moved to the background.
If you need App to send updates to the server, I believe above should be sufficient (unless your app is spying on a user, it should have all relevant data available once the user finishes interaction with the App).
If you need a server to send data to the App, use silent push notification (or background fetch for periodic pulling), or in case this data is critical to the user, you can present him a remote notification - if the user considers that an important update, he will open the app.

Server sends data while iOS app is terminated

I have an application which has communication with a remote server. The server should push data into it using remote notification silently, and I need to get and store these data into a CoreData database. The user won't be aware of the whole process.
I can successfully get notified when the app receives a remote notification, while it is either in the foreground or background mode. However, I need to get data while the app is terminated as well.
I searched for the possible solutions. For example, this SO question was good if I don't tend to use silent notification. I also saw the PushKit capability, but I am not sure about the Apple Review result.
What is the possible solution?
If I want to use VoIP and PushKit to get notified when the app is terminated, would Apple reject my application?
If you’re not creating a VoIP app and you want your app to be in the App Store then the correct answer is: it is not possible. The only thing that can be done is adjusting your requirements in some way.
For instance you can send some notifications that will be visible for user in the Notification Center and wait until the user taps the notification or starts the app the usual way. Then the app will be able to do all the operations you need.
The delivery of push notifications is not guaranteed, so you should not rely on them to synchronise data.
For example, if multiple push notifications are sent while the device is offline, only the last notification is delivered when the device comes back online; the earlier notifications are lost.
When your app launches one of the first things it should do is check with your server for new data.

What is the best way to handle silent push notifications in iOS

We need to calculate some numbers and display the calculations in local notification on receiving a silent push message from the server.
This works when the app is active/open in background.
This does not work if the app is killed/not in background.
So is there anyway to perform tasks when app is closed and the silent push arrives?
FYI I have enabled background fetch.
Apple's Documentation states:
Note: The ability of APNs to deliver remote notifications to a nonrunning
app requires the app to have been launched at least once.
On an iOS device, if a user force-quits your app using the app
multitasking UI, the app does not receive remote notifications until
the user relaunches it.
The second sentence pertains directly to your question; likely not the answer you hoped for...
↳ Configuring Remote Notification Support

Swift iOS: Silent push, triggers app to make sound and vibration?

I am trying to make an app where you could send a warning to other users which then will trigger an alarm on the receivers phone.
So my plan is to send a silent warning to the receiver, which then triggers sounds and vibrations on the receivers phone from the app.
So basically my question is, is it possible to open an app on a phone through a silent push?
This is done with push notifications in iOS. See Apple's description.
Apps must be configured appropriately before they can receive local or remote notifications. The configuration process differs slightly on iOS and OS X, but the basic principles are the same. At launch time, your app registers to receive notifications and works with the system to configure that notification support. Once registration is complete, you can start creating notifications for delivery to your app. Your app then handles these incoming notifications and provides an appropriate response.
But note that it is up to the receiving user to determine how he wants to be alerted.

Using silent push notifications to keep an iOS app in "Background" state

Is it possible to keep an iOS app in "Background" state by sending it a silent push notification every few seconds? I want to run background tasks on a regular interval and this seems like a viable solution. If so, is this acceptable under the App Store terms of use?
The app I am planning to build would rely on this functionality and I am concerned that Apple will reject it from the App Store.
Specifically, it’s this section in the guidelines that I am not sure about:
5.1 Apps that send Push Notifications without first obtaining user consent, as well as apps that require Push Notifications to function, will be rejected
Technically my app could be used without allowing push notifications but it wouldn’t serve its primary function of recording data in the background.
In iOS7 additional background modes were added, you can check out the available background modes here.
IMHO, if you misuse one of the background modes, the app will probably be rejected, saying that , i don't think silent push notifications were meant for: keep an iOS app in "Background" state by sending it a silent push notification every few seconds.
another thing is that silent push notifications are rate limited as described here, so i'm not sure if they will be sent every few seconds.
maybe you can use another background service
This is only possible via Cydia. Which means you will need to have a Repository, and jailbroken device for this to work.
The App Store will surely reject this, as it forces other apps to work in the background.

Resources