我在我的应用中设置了推送通知.我有方法:
- (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo { if() { //app is in foreground to get here } else if() { //app is in background and then the notification is clicked,to get here } }
解决方法
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if ( application.applicationState == UIApplicationStateActive ) // app was already in the foreground else // app was just brought from background to foreground ... }