0

If there possibility launch app when it has received notification (without tapping on notification and if app is closed)? Or if there possibility doing some work in background if app is closed?

Hasya
  • 9,792
  • 4
  • 31
  • 46

2 Answers2

1

Yes, possible with pushkit ( Silent push notification ).

This also works when your app is in terminated state.

Once you receive puskit payload, you can schedule local notification with sound file.

Upto sound file plays, your app will be active in background and you can process your code. ( Sound file max allowed for 30 seconds, so you can execute code upto 30 seconds only )

You need to integrate below things.

  • Pushkit ios code
  • Silent push notification code at server side
  • Required certificate and provisions for iOS and server side code

Note - Your app must be voip based or in specific category with taken prior permission from Apple.

Refer - https://github.com/hasyapanchasara/PushKit_SilentPushNotification

Hasya
  • 9,792
  • 4
  • 31
  • 46
0

You should add content-available key to your payload with value of 1.

According to RemoteNotifications Programming content-available definition is

Provide this key with a value of 1 to indicate that new content is available. Including this key and value means that when your app is launched in the background or resumed, application:didReceiveRemoteNotification:fetchCompletionHandler: is called.

(Newsstand apps are guaranteed to be able to receive at least one push with this key per 24-hour window.)

TawaNicolas
  • 636
  • 1
  • 5
  • 11