我试图在我的游戏中实施应用内购买,但是在我购买优质内容后,我的应用仍然暂停。经过一些试验和错误,我发现我的问题出现在视图控制器中,如果玩家退出我的应用程序,我在其中添加了两个暂停和恢复的功能。看起来购买产品会导致应用程序进入后台,但完成购买并不算作进入前台。有没有办法解决这个问题?
-(void)appWillEnterBackground{
SKView* skview = (SKView*)self.view;
skview.paused = YES;
[[NSNotificationCenter defaultCenter]removeObserver:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:NULL];
}
-(void)appWillEnterForeground{
SKView* skview = (SKView*)self.view;
skview.paused = NO;
[[NSNotificationCenter defaultCenter]removeObserver:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterBackground) name:UIApplicationWillResignActiveNotification object:NULL];
}