I have a game the presents different scenes. every hour a push notification is sent to the phone which passes the level number of the scene, this number that cause different scenes to be presented. everything was working normally. suddenly the scene is not being updated. if i want to update the scene i have to click on a button which take me to another viewController when pressing done and coming back the rootViewController, it presents the new updated scene. Sometimes its working perfectly when pressing on push notification, other times, I have to press a button and go to another view Conroller in order to the updated scene to be presented
the method [self checkSceneLevel] that compare the numbers and present the scenes is called inside ViewWillLayoutSubviews.
I have [delegate addObserver:self forKeyPath:@"currentLevel" options:0 context:nil];
to check for the current level also in viewWillLayoutSubviews.
in the app deletgate i have this defined
`
-(void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"userInfo= %@ ",userInfo);
[self handleBackgroundNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
}
`
- (void)handleBackgroundNotification:(NSDictionary *)notification
{
NSDictionary *aps = (NSDictionary *)[notification objectForKey:@"aps"];
NSMutableString *alert = [NSMutableString stringWithString:@""];
NSDictionary *info=aps[@"info"];
if (info)
{
if (info[@"current_level"]) {
_currentLevel = info[@"current_level"];
[[NSUserDefaults standardUserDefaults] setObject:_currentLevel forKey:@"currentLevel"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
}
can you shed a light on what is the reason behind this weird and sudden behaviour?