File tree Expand file tree Collapse file tree 6 files changed +25
-2
lines changed
Expand file tree Collapse file tree 6 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 11#import < React/RCTEventEmitter.h>
22
33static NSString * const RNRegistered = @" remoteNotificationsRegistered" ;
4+ static NSString * const RNRegistrationDenied = @" remoteNotificationsRegistrationDenied" ;
45static NSString * const RNRegistrationFailed = @" remoteNotificationsRegistrationFailed" ;
56static NSString * const RNPushKitRegistered = @" pushKitRegistered" ;
67static NSString * const RNNotificationReceived = @" notificationReceived" ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ @implementation RNEventEmitter
66
77-(NSArray <NSString *> *)supportedEvents {
88 return @[RNRegistered,
9+ RNRegistrationDenied,
910 RNRegistrationFailed,
1011 RNPushKitRegistered,
1112 RNNotificationReceived,
Original file line number Diff line number Diff line change 1+ #import " RNEventEmitter.h"
12#import " RNNotificationCenter.h"
23#import " RCTConvert+RNNotifications.h"
34
@@ -40,6 +41,9 @@ - (void)requestPermissions:(NSDictionary *)options {
4041 }
4142 }];
4243 }
44+ if (!error && !granted) {
45+ [RNEventEmitter sendEvent: RNRegistrationDenied body: nil ];
46+ }
4347 }];
4448}
4549
Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ export class NativeEventsReceiver {
2525 }
2626
2727 public registerNotificationReceived ( callback : ( notification : Notification ) => void ) : EmitterSubscription {
28- return this . emitter . addListener ( 'notificationReceived' , ( payload ) => {
28+ return this . emitter . addListener ( 'notificationReceived' , ( payload : unknown ) => {
2929 callback ( this . notificationFactory . fromPayload ( payload ) ) ;
3030 } ) ;
3131 }
3232
3333 public registerNotificationReceivedBackground ( callback : ( notification : Notification ) => void ) : EmitterSubscription {
34- return this . emitter . addListener ( 'notificationReceivedBackground' , ( payload ) => {
34+ return this . emitter . addListener ( 'notificationReceivedBackground' , ( payload : unknown ) => {
3535 callback ( this . notificationFactory . fromPayload ( payload ) ) ;
3636 } ) ;
3737 }
@@ -50,4 +50,8 @@ export class NativeEventsReceiver {
5050 public registerRemoteNotificationsRegistrationFailed ( callback : ( event : RegistrationError ) => void ) : EmitterSubscription {
5151 return this . emitter . addListener ( 'remoteNotificationsRegistrationFailed' , callback ) ;
5252 }
53+
54+ public registerRemoteNotificationsRegistrationDenied ( callback : ( ) => void ) : EmitterSubscription {
55+ return this . emitter . addListener ( 'remoteNotificationsRegistrationDenied' , callback ) ;
56+ }
5357}
Original file line number Diff line number Diff line change @@ -34,4 +34,8 @@ export class EventsRegistry {
3434 public registerRemoteNotificationsRegistrationFailed ( callback : ( event : RegistrationError ) => void ) : EmitterSubscription {
3535 return this . nativeEventsReceiver . registerRemoteNotificationsRegistrationFailed ( callback ) ;
3636 }
37+
38+ public registerRemoteNotificationsRegistrationDenied ( callback : ( ) => void ) : EmitterSubscription {
39+ return this . nativeEventsReceiver . registerRemoteNotificationsRegistrationDenied ( callback ) ;
40+ }
3741}
Original file line number Diff line number Diff line change @@ -59,4 +59,13 @@ Fired when the user fails to register for remote notifications. Typically occurs
5959Notifications .events ().registerRemoteNotificationsRegistrationFailed ((event : RegistrationError ) => {
6060 console .log (event .code , event .localizedDescription , event .domain );
6161});
62+ ```
63+
64+ ## registerRemoteNotificationsDenied()
65+ Fired when the user does not grant permission to receive push notifications. Typically occurs when pressing the "Don't Allow" button in iOS permissions overlay.
66+
67+ ``` js
68+ Notifications .events ().registerRemoteNotificationRegistrationDenied (() => {
69+ console .log (' Notification permissions not granted' )
70+ })
6271```
You can’t perform that action at this time.
0 commit comments