Only start observing in requestPermissions() if not already observing
Reviewed By: javache Differential Revision: D4903744 fbshipit-source-id: d2700f59bae521de6c76f8a3d11d6d48f1c0e7d9
This commit is contained in:
parent
c58e19ef33
commit
bd0f9fbacb
|
@ -142,11 +142,6 @@ RCT_EXPORT_MODULE()
|
|||
selector:@selector(handleRemoteNotificationReceived:)
|
||||
name:RCTRemoteNotificationReceived
|
||||
object:nil];
|
||||
[self startObservingRegistrationNotifications];
|
||||
}
|
||||
|
||||
- (void)startObservingRegistrationNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleRegisterUserNotificationSettings:)
|
||||
name:RCTRegisterUserNotificationSettings
|
||||
|
@ -281,6 +276,8 @@ RCT_EXPORT_MODULE()
|
|||
};
|
||||
|
||||
_requestPermissionsResolveBlock(notificationTypes);
|
||||
// Clean up listener added in requestPermissions
|
||||
[self removeListeners:1];
|
||||
_requestPermissionsResolveBlock = nil;
|
||||
}
|
||||
|
||||
|
@ -324,7 +321,8 @@ RCT_EXPORT_METHOD(requestPermissions:(NSDictionary *)permissions
|
|||
return;
|
||||
}
|
||||
|
||||
[self startObservingRegistrationNotifications];
|
||||
// Add a listener to make sure that startObserving has been called
|
||||
[self addListener:@"remoteNotificationsRegistered"];
|
||||
_requestPermissionsResolveBlock = resolve;
|
||||
|
||||
UIUserNotificationType types = UIUserNotificationTypeNone;
|
||||
|
|
|
@ -38,4 +38,7 @@
|
|||
- (void)startObserving;
|
||||
- (void)stopObserving;
|
||||
|
||||
- (void)addListener:(NSString *)eventName;
|
||||
- (void)removeListeners:(NSInteger)count;
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue