iOS not calling applicationDidEnterBackground / applicationWillEnterForeground anymore on 3.17.2

Hello,

On iOS I do not receive anymore calls to applicationDidEnterBackground / applicationWillEnterForeground.
For that reason, the game is not pausing / resuming, creating big problems.

I’m using 3.17.2 and that’s quite strange because I developed an older game (always with 3.17.2) and I’m getting these calls correctly (applicationDidEnterBackground / applicationWillEnterForeground).
Any idea why?

I know it could be related to iOS13 and new UIScene management, but it doesnt work for me.
I’ve added additional notifications:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive:) name:UISceneWillDeactivateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActive:) name:UISceneDidActivateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidEnterBackground:) name:UISceneDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterForeground:) name:UISceneWillEnterForegroundNotification object:nil];

No luck … maybe I’m doing something wrong?
In any case, very strange my older 3.17.2 project still work …

Does running cocos new ... and building it result in applicationDidEnterBackground() and applicationWillEnterForeground() not getting called?

Thanks for your answer.

I was searching a bit more and I found out that Google Admob generates the “problem”.

If I add “GoogleMobileAds.framework”, then I stop getting applicationDidEnterBackground() and applicationWillEnterForeground() on my AppController.mm file.
I’m using latest GoogleMobileAdsSdkiOS-7.58.0.

To answer your question, these functions on AppController.mm never get called anymore after adding Admob when pausing/resuming my game:

  • (void)applicationWillResignActive:(UIApplication *)application
  • (void)applicationDidBecomeActive:(UIApplication *)application
  • (void)applicationDidEnterBackground:(UIApplication *)application
  • (void)applicationWillEnterForeground:(UIApplication *)application

and thus, I cannot properly call:
cocos2d::Application::getInstance()->applicationDidEnterBackground();
cocos2d::Application::getInstance()->applicationWillEnterForeground();

I’ll keep you informed if I can find a solution

I fixed by adding a SceneDelegate to manage UIScene on iOS13.
Hardest part was keep it compatible with iOS12 devices and older because it’s really hard to test them without a proper simulator.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.