我在我的应用中设置了推送通知.我有方法:
- (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 ... }