Guest User

Untitled

a guest
Feb 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { //处理远程通知——应用正在运行 
  2. if(application.applicationState == UIApplicationStateInactive) {
  3. //用户点击通知中心的通知或报警弹窗
  4. [self processRemoteNotification:userInfo];
  5. } else if(application.applicationState == UIApplicationStateBackground) {
  6. //应用在后台,不存在用户交互——只是获取数据 } else {
  7. //应用已经处于激活状态——显示应用内的更新 }
  8. }
  9.  
  10. -(void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  11. id notification = [launchOptions
  12. objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
  13. if(notification != nil) {
  14. NSDictionary *userInfo = (NSDictionary *)notification;  [self processRemoteNotification:userInfo];
  15. }
  16. }
  17.  
  18. -(void)processRemoteNotification:(NSDictionary *)userInfo { }
Add Comment
Please, Sign In to add comment