- (void)userNotificationCenter:(UNUserNotificationCenter )center…
Jump to turn (12)
- 1(void)userNotificationCenter:(UNUserNotificationCenter )center didReceiveNotific
- 2报这个错误是什么原因:Use of undeclared identifier 'kGCMMessageIDKey'
- 3能不能使用运行时代码获取这个常量
- 4(void)userNotificationCenter:(UNUserNotificationCenter )center didReceiveNotific
- 5(void)application:(UIApplication )application didReceiveRemoteNotification:(NSDi
- 6OC中重复声明的方法如何处理
- 7讲讲这段代码-(void) firAppConfire { if (self.sharedFirConfired) { return; } [CmgeFireb
- 8Xcode中的background modes是什么功能
- 9background processing负责什么
- 10讲讲这段代码-(void) registerRemoteNotifictionWithGrantHandler:(void (^)(BOOL, NSError
- 11这段代码为什么这样写
- 12@property (nonatomic, copy) void (^afterGrandRegisterRemoteHandler)(BOOL, NSErro
- User
-
(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler { NSDictionary *userInfo = response.notification.request.content.userInfo; if (userInfo[kGCMMessageIDKey]) { NSLog(@"Message ID: %@", userInfo[kGCMMessageIDKey]); }
// With swizzling disabled you must let Messaging know about the message, for Analytics // [[FIRMessaging messaging] appDidReceiveMessage:userInfo];
// Print full message. NSLog(@"%@", userInfo);
completionHandler(); } 讲讲这段代码
-
- Assistant
这段代码是实现了
UNUserNotificationCenterDelegate协议中的方法,当用户点击通知时会调用该方法。方法中首先获取通知中的userInfo,并判断其中是否包含kGCMMessageIDKey,如果存在则打印出消息 ID。之后,该方法还可以调用 Firebase Messaging 中的
appDidReceiveMessage方法,用于在分析中跟踪消息接收情况。最后,该方法通过 告知系统通知已经处理完成。