0

I know this is not the first version of this kind of question - but all information I found seems to be outdated or even wrong. So I decided to ask the question again.

Currently I'm using remote notifications to send notifications to my iOS device. Because I'd like to "awake" my application every hour (even if the app was force closed by the user) my idea was to use silent-push notifications.

Just sending Notifications is working quite well - even in the background or after force-closed by the user. But how to wake my application when it's force-closed to perform a background task by using silent-push-notifications?

func application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        let aps = userInfo["aps"] as! [String: AnyObject] { // remote information
        completionHandler(.newData) // call completion handler
}



This is the raw of the notification:

send notification but doesn't perform background task (doesn't awake my app)


{
  "aps" : {
    "alert" : {
      "title" : "..."
    },
    "content-available" : 1,
    "information" : "abc"
  }
}

also doesn't perform background task (doesn't wake my app)


{
  "aps" : {
    "content-available" : 1,
    "information" : "abc"
  }
}
jscs
  • 63,694
  • 13
  • 151
  • 195
  • 1
    EDIT: When my application is not force-closed but just in background mode I'm able to awake my app. But after I've suspended the app by double-clicking & swiping up, I'm able to receive notifications but I'm not able to awake my application. Seems like `didReceiveRemoteNotification` is not getting called anymore. –  Feb 03 '18 at 11:56
  • 2
    If your app is force closed then iOS will not relaunch it for a silent push. The user killed it, so it is dead. Push kit can be used with VoIP apps to relaunch an app, but it doesn't sound as if your app is a voip app. – Paulw11 Feb 03 '18 at 20:27

0 Answers0