File tree 6 files changed +25
-2
lines changed
6 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1
1
#import < React/RCTEventEmitter.h>
2
2
3
3
static NSString * const RNRegistered = @" remoteNotificationsRegistered" ;
4
+ static NSString * const RNRegistrationDenied = @" remoteNotificationsRegistrationDenied" ;
4
5
static NSString * const RNRegistrationFailed = @" remoteNotificationsRegistrationFailed" ;
5
6
static NSString * const RNPushKitRegistered = @" pushKitRegistered" ;
6
7
static NSString * const RNNotificationReceived = @" notificationReceived" ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ @implementation RNEventEmitter
6
6
7
7
-(NSArray <NSString *> *)supportedEvents {
8
8
return @[RNRegistered,
9
+ RNRegistrationDenied,
9
10
RNRegistrationFailed,
10
11
RNPushKitRegistered,
11
12
RNNotificationReceived,
Original file line number Diff line number Diff line change
1
+ #import " RNEventEmitter.h"
1
2
#import " RNNotificationCenter.h"
2
3
#import " RCTConvert+RNNotifications.h"
3
4
@@ -40,6 +41,9 @@ - (void)requestPermissions:(NSDictionary *)options {
40
41
}
41
42
}];
42
43
}
44
+ if (!error && !granted) {
45
+ [RNEventEmitter sendEvent: RNRegistrationDenied body: nil ];
46
+ }
43
47
}];
44
48
}
45
49
Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ export class NativeEventsReceiver {
25
25
}
26
26
27
27
public registerNotificationReceived ( callback : ( notification : Notification ) => void ) : EmitterSubscription {
28
- return this . emitter . addListener ( 'notificationReceived' , ( payload ) => {
28
+ return this . emitter . addListener ( 'notificationReceived' , ( payload : unknown ) => {
29
29
callback ( this . notificationFactory . fromPayload ( payload ) ) ;
30
30
} ) ;
31
31
}
32
32
33
33
public registerNotificationReceivedBackground ( callback : ( notification : Notification ) => void ) : EmitterSubscription {
34
- return this . emitter . addListener ( 'notificationReceivedBackground' , ( payload ) => {
34
+ return this . emitter . addListener ( 'notificationReceivedBackground' , ( payload : unknown ) => {
35
35
callback ( this . notificationFactory . fromPayload ( payload ) ) ;
36
36
} ) ;
37
37
}
@@ -50,4 +50,8 @@ export class NativeEventsReceiver {
50
50
public registerRemoteNotificationsRegistrationFailed ( callback : ( event : RegistrationError ) => void ) : EmitterSubscription {
51
51
return this . emitter . addListener ( 'remoteNotificationsRegistrationFailed' , callback ) ;
52
52
}
53
+
54
+ public registerRemoteNotificationsRegistrationDenied ( callback : ( ) => void ) : EmitterSubscription {
55
+ return this . emitter . addListener ( 'remoteNotificationsRegistrationDenied' , callback ) ;
56
+ }
53
57
}
Original file line number Diff line number Diff line change @@ -34,4 +34,8 @@ export class EventsRegistry {
34
34
public registerRemoteNotificationsRegistrationFailed ( callback : ( event : RegistrationError ) => void ) : EmitterSubscription {
35
35
return this . nativeEventsReceiver . registerRemoteNotificationsRegistrationFailed ( callback ) ;
36
36
}
37
+
38
+ public registerRemoteNotificationsRegistrationDenied ( callback : ( ) => void ) : EmitterSubscription {
39
+ return this . nativeEventsReceiver . registerRemoteNotificationsRegistrationDenied ( callback ) ;
40
+ }
37
41
}
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
59
59
Notifications .events ().registerRemoteNotificationsRegistrationFailed ((event : RegistrationError ) => {
60
60
console .log (event .code , event .localizedDescription , event .domain );
61
61
});
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
+ })
62
71
```
You can’t perform that action at this time.
0 commit comments