我现在是要区分点击通知栏的通知进入应用还是点击应用图标进入的,1,开始程序都是在后台。2,接受通知都是在foreground状态。applicationdidFinishLaunchWithOptions程序第一次启动才会执行,与远程通知无关
application:(UIApplication *)application didReceiveRemoteNotification:无论怎么进入程序,都是在foreground状态才会执行。所以现在要区分是从通知栏进入还是点击图标进入遇到问题。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    BOOL bActivatedByNotification=NO;
    if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive)
        bActivatedByNotification=YES;

}