应用程序不管在后台还是前台都会执行
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
判断应用程序在前台还是后台
[UIApplication sharedApplication].applicationState == UIApplicationStateActive 这是在前台 UIApplicationStateActive //这是在后台 UIApplicationStateBackground