Sauron
Sauron

Reputation: 6647

Enable iOS notification to activate background service

Within iOS, upon receiving a notification in the lock screen, I need a background service within my app to start up.

I know this can occur in Android, but is this possible within iOS?

Upvotes: 0

Views: 82

Answers (2)

Scrungepipes
Scrungepipes

Reputation: 37581

The equivalent of an Android service does not exist in iOS.

There are two types of push, one that is sent to the app and one that is sent to the user.

If a push is sent to the user then:
- if your app is terminated, the push is displayed to the user
- if your app is in the background, the push is displayed to the user
- if your app is in the foreground, the push is delivered to the app.
If a push is sent to the app then:
- if your app is terminated, the push goes nowhere
- if your app is in the background, the push is sent to the app, and you *may* be able to perform some activity at that point, depending upon your background modes.
- if your app is in the foreground, the push is sent to the app.

(In addition to that, in iOS 10, pushes directed to the user can be intercepted and their content changed before they are displayed to the user. But they are not intercepted by your app, they are intercepted by an extension that is part of your app. But this does not mean you app can run at this point.)

So the answer to your question is no, because services do not exist. The answer to if you can run in the background when a app push is sent, is only if the app is not terminated and you have certain background capabilities. Due to the termination factor, it is not therefore a mechanism you can rely on.

Upvotes: 1

matt
matt

Reputation: 534885

If the user taps the notification alert, your app is sent an event in the background and is now running in the background (and you can even require that this means your app is brought to the foreground).

Upvotes: 1

Related Questions