2 Replies
      Latest reply on Dec 21, 2015 2:40 AM by eskimo
      yuhirb Level 1 Level 1 (0 points)

        Hello.

        Our app fetches new contents using NSURLSession when the app receive silent push notification in background.


        Receiving notification in “Suspended” state (the app remains in memory) it works perfectly. In “Not running” state, the system wakes the app in the background and the app can send request via NSURLSessionDataTask but completion handler of data task is not called.

         

        func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
            let request: NSURLRequest = ...
            let task: NSURLSessionDataTask = NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
                // This closure is not called when the app is woken from "Not Running". 
                let localNotification: UILocalNotification = UILocalNotification()
                localNotification.alertBody = "task completed"
                localNotification.soundName = UILocalNotificationDefaultSoundName
                application.presentLocalNotificationNow(localNotification)
                completionHandler(UIBackgroundFetchResult.NewData)
            })
            task.resume()
        }
        
        
        
        

         

        The reference says "the system does not automatically launch your app if the user has force-quit it". We have the issue though the user does not force quit the app. Could anyone help us?

         

        Thanks.