1

I want to download data when receiving a push notification while the app is not active.

I enabled push notifications in background mode.

This is my code :

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
    println("App is alive !!!")
    downloadData(){
        (success:Bool) -> Void in
        println("data downloaded : \(success)")
        var result = success ? UIBackgroundFetchResult.NewData : UIBackgroundFetchResult.Failed
        completionHandler(result)
    }
}

I launch the app in debug mode, I leave it. I receive a push notification. The data is not downloaded.

I don't even know if the the didReceiveRemoteNotification has been called.

What am I doing wrong ?

Cherif
  • 5,223
  • 8
  • 33
  • 54

0 Answers0