From aba18fd085b7d9d92dd94f4058188e31ce6b953e Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Wed, 21 Sep 2016 22:49:27 -0400 Subject: [PATCH] combine notification handler iOS --- ios/RNFIRMessaging.h | 1 - ios/RNFIRMesssaging.m | 16 ++-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/ios/RNFIRMessaging.h b/ios/RNFIRMessaging.h index 0e73704..702c1ee 100644 --- a/ios/RNFIRMessaging.h +++ b/ios/RNFIRMessaging.h @@ -8,7 +8,6 @@ extern NSString *const FCMNotificationReceived; -extern NSString *const FCMLocalNotificationReceived; @interface RNFIRMessaging : NSObject diff --git a/ios/RNFIRMesssaging.m b/ios/RNFIRMesssaging.m index 1676bbd..68c2ca8 100644 --- a/ios/RNFIRMesssaging.m +++ b/ios/RNFIRMesssaging.m @@ -18,7 +18,6 @@ #endif NSString *const FCMNotificationReceived = @"FCMNotificationReceived"; -NSString *const FCMLocalNotificationReceived = @"FCMLocalNotificationReceived"; @implementation RCTConvert (NSCalendarUnit) @@ -84,7 +83,7 @@ RCT_EXPORT_MODULE() _bridge = bridge; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(handleRemoteNotificationReceived:) + selector:@selector(handleNotificationReceived:) name:FCMNotificationReceived object:nil]; @@ -97,10 +96,6 @@ RCT_EXPORT_MODULE() name:UIApplicationDidBecomeActiveNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(handleFCMLocalNotificationReceived:) - name:FCMLocalNotificationReceived - object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onTokenRefresh) name:kFIRInstanceIDTokenRefreshNotification object:nil]; @@ -279,14 +274,7 @@ RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTP resolve(@([RCTSharedApplication() applicationIconBadgeNumber])); } -- (void)handleFCMLocalNotificationReceived:(UILocalNotification *)notification -{ - NSMutableDictionary *data = [[NSMutableDictionary alloc]initWithDictionary: notification.userInfo]; - [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"]; - [_bridge.eventDispatcher sendDeviceEventWithName:FCMLocalNotificationReceived body:data]; -} - -- (void)handleRemoteNotificationReceived:(NSNotification *)notification +- (void)handleNotificationReceived:(NSNotification *)notification { NSMutableDictionary *data = [[NSMutableDictionary alloc]initWithDictionary: notification.userInfo]; [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"]; -- 2.26.2