Created
February 15, 2019 07:43
-
-
Save Andrewmika/53793dab75aa776aedf953a6cf6d2000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { //处理远程通知——应用正在运行 | |
if(application.applicationState == UIApplicationStateInactive) { | |
//用户点击通知中心的通知或报警弹窗 | |
[self processRemoteNotification:userInfo]; | |
} else if(application.applicationState == UIApplicationStateBackground) { | |
//应用在后台,不存在用户交互——只是获取数据 } else { | |
//应用已经处于激活状态——显示应用内的更新 } | |
} | |
-(void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
id notification = [launchOptions | |
objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; | |
if(notification != nil) { | |
NSDictionary *userInfo = (NSDictionary *)notification; [self processRemoteNotification:userInfo]; | |
} | |
} | |
-(void)processRemoteNotification:(NSDictionary *)userInfo { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment