Search code examples
iphonebackgroundjailbreakuiapplicationdelegate

UIApplicationDelegate not called when using Backgrounder on a jailbroken device


I'm running into a bit of an issue. My software needs to know when the application is in background so it will disconnect from the server, and start receiving push notifications.

For that I use UIApplicationDelegate's method :

- (void)applicationWillResignActive:(UIApplication *)application
- (void)applicationDidEnterBackground:(UIApplication *)application
- (void)applicationWillEnterForeground:(UIApplication *)application
- (void)applicationDidBecomeActive:(UIApplication *)application
- (void)applicationWillTerminate:(UIApplication *)application

The problem is, when a jailbroken device is using the "tweak" called backgrounder, that will force your application to stay active and not going into background, none of the UIApplicationDelegate's method get called when we click on the HOME button.

The thing is, each client connected in SSL cost me a lot of memory on the server. I do not really care that the device is jailbroken, or as a matter a fact, the application will run indefinitely on the device. But I would like them to disconnect from the server when the application is no longer on the screen, but I can't seems to find any method that will inform me of such operation when backgrounder is installed.

Solution find : check my own answer on the post


Solution

  • Milk Tea got me on the right track... So the bounty goes to him.

    But actually I got a better solution... I have checked every single notifications thrown when resigning the App...

    and I got this, even with backgrounder configured to keep the App open, those notifications are thrown :

    UIApplicationSuspendedEventsOnlyNotification -- When going into background
    UIApplicationResumedEventsOnlyNotification   -- When going into foreground
    

    This makes sense, since even with backgrounder, it would have been a bad idea to let the App keep receiving events notifications, for example, when a change of rotation (or a shake) is done outside the App. Do you imagine every App doing a rotation on background everytime you move your iphone ?