|
@@ -78,39 +78,66 @@ RCT_EXPORT_METHOD(unsetAccount:(NSString *)text)
|
|
|
|
|
|
+ (void)application:(id)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
|
|
|
- NSLog(@"deviceToken:%@", deviceToken);
|
|
|
[MiPushSDK bindDeviceToken:deviceToken];
|
|
|
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
|
|
}
|
|
|
|
|
|
+ (void)application:(id)application didReceiveRemoteNotification:(NSDictionary *)notification {
|
|
|
-
|
|
|
+
|
|
|
[RCTPushNotificationManager didReceiveRemoteNotification:notification];
|
|
|
}
|
|
|
|
|
|
+ (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
|
|
-
|
|
|
+
|
|
|
[RCTPushNotificationManager didReceiveLocalNotification:notification];
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"xmpush_click" object:notification.userInfo];
|
|
|
}
|
|
|
|
|
|
// 应用在前台收到通知
|
|
|
+ (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
|
|
|
-
|
|
|
+
|
|
|
NSDictionary * userInfo = notification.request.content.userInfo;
|
|
|
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
|
|
-
|
|
|
+
|
|
|
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 点击通知进入应用
|
|
|
+ (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
|
|
|
-
|
|
|
NSDictionary * userInfo = response.notification.request.content.userInfo;
|
|
|
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
|
|
-
|
|
|
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo];
|
|
|
}
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"xmpush_click" object:userInfo];
|
|
|
+ completionHandler();
|
|
|
+}
|
|
|
+
|
|
|
+- (void) handleSend:(NSNotification *)notification {
|
|
|
+
|
|
|
+ [self sendEventWithName:notification.name body:notification.object];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)startObserving
|
|
|
+{
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
+ selector:@selector(handleSend:)
|
|
|
+ name:@"xmpush_click"
|
|
|
+ object:nil];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)stopObserving
|
|
|
+{
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
+}
|
|
|
+
|
|
|
+- (NSArray<NSString *> *)supportedEvents {
|
|
|
+ NSMutableArray *arr = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ [arr addObject:@"xmpush_click"];
|
|
|
+
|
|
|
+ return arr;
|
|
|
}
|
|
|
|
|
|
@end
|