Commit aba18fd0 authored by Libin Lu's avatar Libin Lu

combine notification handler iOS

parent 01f41d97
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
extern NSString *const FCMNotificationReceived; extern NSString *const FCMNotificationReceived;
extern NSString *const FCMLocalNotificationReceived;
@interface RNFIRMessaging : NSObject <RCTBridgeModule> @interface RNFIRMessaging : NSObject <RCTBridgeModule>
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#endif #endif
NSString *const FCMNotificationReceived = @"FCMNotificationReceived"; NSString *const FCMNotificationReceived = @"FCMNotificationReceived";
NSString *const FCMLocalNotificationReceived = @"FCMLocalNotificationReceived";
@implementation RCTConvert (NSCalendarUnit) @implementation RCTConvert (NSCalendarUnit)
...@@ -84,7 +83,7 @@ RCT_EXPORT_MODULE() ...@@ -84,7 +83,7 @@ RCT_EXPORT_MODULE()
_bridge = bridge; _bridge = bridge;
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRemoteNotificationReceived:) selector:@selector(handleNotificationReceived:)
name:FCMNotificationReceived name:FCMNotificationReceived
object:nil]; object:nil];
...@@ -97,10 +96,6 @@ RCT_EXPORT_MODULE() ...@@ -97,10 +96,6 @@ RCT_EXPORT_MODULE()
name:UIApplicationDidBecomeActiveNotification name:UIApplicationDidBecomeActiveNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleFCMLocalNotificationReceived:)
name:FCMLocalNotificationReceived
object:nil];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(onTokenRefresh) addObserver:self selector:@selector(onTokenRefresh)
name:kFIRInstanceIDTokenRefreshNotification object:nil]; name:kFIRInstanceIDTokenRefreshNotification object:nil];
...@@ -279,14 +274,7 @@ RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTP ...@@ -279,14 +274,7 @@ RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTP
resolve(@([RCTSharedApplication() applicationIconBadgeNumber])); resolve(@([RCTSharedApplication() applicationIconBadgeNumber]));
} }
- (void)handleFCMLocalNotificationReceived:(UILocalNotification *)notification - (void)handleNotificationReceived:(NSNotification *)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
{ {
NSMutableDictionary *data = [[NSMutableDictionary alloc]initWithDictionary: notification.userInfo]; NSMutableDictionary *data = [[NSMutableDictionary alloc]initWithDictionary: notification.userInfo];
[data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"]; [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment