0

In my application background mode is enabled because I'm using bluetooth functionality. When I put my app in the background. I'm using UIBackgroundTaskIdentifier to perform task in the background. But When this background task is finished didfinishlaunching is called. Because of this when I launch my app first screen of the app comes in. I have captured the logs.Following is the logs when app goes in background:

New Line Time: 2018-02-02 12:37:39 +0000, applicationDidEnterBackground -----

New Line Time: 2018-02-02 12:37:39 +0000, stop tracking in background

New Line Time: 2018-02-02 12:40:35 +0000, backgroundTaskIdentifier finished -----

New Line Time: 2018-02-02 12:45:50 +0000, didfinishlaunching

NatwarAnil
  • 31
  • 6
  • Are you sure your app isn't just being terminated for exceeding 3 minutes with a background task active and then being relaunched later. What are you doing in the background task? – Paulw11 Feb 02 '18 at 19:43
  • I don't think so. As you can see the log I'm also stopping location update. App just needs to wake up when gets any alert from blue tooth device. – NatwarAnil Feb 02 '18 at 19:53
  • 1
    I see a 3 minute period between entering the background and your background task finishing and then an 5 minute period before you are relaunched. 3 minutes is the limit of how long you can have a background task before your app is terminated. Why are you using a background task? Neither Bluetooth nor background location requires one. – Paulw11 Feb 02 '18 at 20:06
  • I need to send the alert received from blue tooth device to a server. When I was not using this background task I was getting any alert from blue tooth device after some time when app want to the background. So I used this task and eventually my app started getting alert. – NatwarAnil Feb 02 '18 at 20:19
  • **New Line** Time: 2018-02-02 12:45:56 +0000, applicationDidEnterBackground ----- **New Line** Time: 2018-02-02 12:45:56 +0000, stop tracking in background **New Line** Time: 2018-02-02 13:23:34 +0000, backgroundTaskIdentifier finished ----- **New Line** Time: 2018-02-02 14:41:09 +0000, Func = didConnectPeripheral – NatwarAnil Feb 02 '18 at 20:25
  • **New Line** Time: 2018-02-02 12:45:56 +0000, applicationDidEnterBackground ----- **New Line** Time: 2018-02-02 12:45:56 +0000, stop tracking in background **New Line** Time: 2018-02-02 13:23:34 +0000, backgroundTaskIdentifier finished ----- **New Line** Time: 2018-02-02 14:41:09 +0000, Func = didConnectPeripheral If you see these logs there is a much larger time gap between entering background and background task finish. But here didfinishlaunching is not called. – NatwarAnil Feb 02 '18 at 20:28

0 Answers0