Commit f918b56f authored by Libin Lu's avatar Libin Lu Committed by GitHub

backward compatible for addListener

parent 11a6acfe
...@@ -217,6 +217,10 @@ RCT_MULTI_ENUM_CONVERTER(UNNotificationCategoryOptions, (@{ ...@@ -217,6 +217,10 @@ RCT_MULTI_ENUM_CONVERTER(UNNotificationCategoryOptions, (@{
@end @end
@interface RCTEventEmitter ()
- (void) addListener:(NSString *)eventName;
@end
@interface RNFIRMessaging () @interface RNFIRMessaging ()
@property (nonatomic, strong) NSMutableDictionary *notificationCallbacks; @property (nonatomic, strong) NSMutableDictionary *notificationCallbacks;
@end @end
...@@ -318,6 +322,12 @@ RCT_EXPORT_MODULE(); ...@@ -318,6 +322,12 @@ RCT_EXPORT_MODULE();
[[FIRMessaging messaging] setDelegate:self]; [[FIRMessaging messaging] setDelegate:self];
}); });
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if(!jsHandlerRegistered){
[self sendPendingNotifications];
}
});
return self; return self;
} }
...@@ -325,6 +335,11 @@ RCT_EXPORT_MODULE(); ...@@ -325,6 +335,11 @@ RCT_EXPORT_MODULE();
[super addListener:eventName]; [super addListener:eventName];
if([eventName isEqualToString:FCMNotificationReceived]) { if([eventName isEqualToString:FCMNotificationReceived]) {
[self sendPendingNotifications];
}
}
-(void) sendPendingNotifications {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
jsHandlerRegistered = true; jsHandlerRegistered = true;
...@@ -336,7 +351,6 @@ RCT_EXPORT_MODULE(); ...@@ -336,7 +351,6 @@ RCT_EXPORT_MODULE();
[pendingNotifications removeAllObjects]; [pendingNotifications removeAllObjects];
}); });
}
} }
RCT_EXPORT_METHOD(enableDirectChannel) RCT_EXPORT_METHOD(enableDirectChannel)
......
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