Commit aba18fd0 authored by Libin Lu's avatar Libin Lu

combine notification handler iOS

parent 01f41d97
......@@ -8,7 +8,6 @@
extern NSString *const FCMNotificationReceived;
extern NSString *const FCMLocalNotificationReceived;
@interface RNFIRMessaging : NSObject <RCTBridgeModule>
......
......@@ -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"];
......
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