This repository was archived by the owner on Jan 14, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +43
-10
lines changed
android/src/main/java/com/dieam/reactnativepushnotification/modules Expand file tree Collapse file tree 6 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -418,6 +418,11 @@ Removes the specified notifications from Notification Center
418
418
| ----------- | ----- | -------- | ---------------------------------- |
419
419
| identifiers | array | Yes | Array of notification identifiers. |
420
420
421
+
422
+ ## Abandon Permissions
423
+
424
+ ` PushNotification.abandonPermissions() ` Revokes the current token and unregister for all remote notifications received via APNS or FCM.
425
+
421
426
## Notification priority
422
427
423
428
(optional) Specify ` priority ` to set priority of notification. Default value: "high"
@@ -547,5 +552,3 @@ Same parameters as `PushNotification.localNotification()`
547
552
## iOS Only Methods
548
553
549
554
` PushNotification.getApplicationIconBadgeNumber(callback: Function) ` Get badge number
550
-
551
- ` PushNotification.abandonPermissions() ` Unregister for all remote notifications received via Apple Push Notification service.
Original file line number Diff line number Diff line change 25
25
import com .facebook .react .bridge .ReadableMap ;
26
26
import com .facebook .react .bridge .WritableMap ;
27
27
28
+ import java .io .IOException ;
28
29
import java .util .HashMap ;
29
30
import java .util .Map ;
30
31
import java .util .Random ;
@@ -258,4 +259,17 @@ public void getDeliveredNotifications(Callback callback) {
258
259
public void removeDeliveredNotifications (ReadableArray identifiers ) {
259
260
mRNPushNotificationHelper .clearDeliveredNotifications (identifiers );
260
261
}
262
+
263
+ @ ReactMethod
264
+ /**
265
+ * Unregister for all remote notifications received
266
+ */
267
+ public void abandonPermissions () {
268
+ try {
269
+ FirebaseInstanceId .getInstance ().deleteInstanceId ();
270
+ } catch (IOException e ) {
271
+ Log .e (LOG_TAG , "exception" , e );
272
+ return ;
273
+ }
274
+ }
261
275
}
Original file line number Diff line number Diff line change @@ -61,10 +61,6 @@ NotificationsComponent.prototype.setApplicationIconBadgeNumber = function(number
61
61
RNPushNotification . setApplicationIconBadgeNumber ( number ) ;
62
62
} ;
63
63
64
- NotificationsComponent . prototype . abandonPermissions = function ( ) {
65
- /* Void */
66
- } ;
67
-
68
64
NotificationsComponent . prototype . checkPermissions = function ( callback ) {
69
65
RNPushNotification . checkPermissions ( ) . then ( alert => callback ( { alert } ) ) ;
70
66
} ;
@@ -131,6 +127,10 @@ NotificationsComponent.prototype.removeDeliveredNotifications = function(identif
131
127
RNPushNotification . removeDeliveredNotifications ( identifiers ) ;
132
128
}
133
129
130
+ NotificationsComponent . prototype . abandonPermissions = function ( ) {
131
+ RNPushNotification . abandonPermissions ( ) ;
132
+ }
133
+
134
134
module . exports = {
135
135
state : false ,
136
136
component : new NotificationsComponent ( )
Original file line number Diff line number Diff line change @@ -98,6 +98,17 @@ export default class App extends Component {
98
98
} } >
99
99
< Text > Request Permissions</ Text >
100
100
</ TouchableOpacity >
101
+ < TouchableOpacity
102
+ style = { styles . button }
103
+ onPress = { ( ) => {
104
+ this . notif . abandonPermissions ( ) ;
105
+ Alert . alert (
106
+ 'Abandon Permissions' ,
107
+ 'Reload the app to register again with a new token'
108
+ ) ;
109
+ } } >
110
+ < Text > Abandon Permissions</ Text >
111
+ </ TouchableOpacity >
101
112
102
113
< View style = { styles . spacer } > </ View >
103
114
Original file line number Diff line number Diff line change @@ -98,4 +98,8 @@ export default class NotifService {
98
98
cancelAll ( ) {
99
99
PushNotification . cancelAllLocalNotifications ( ) ;
100
100
}
101
+
102
+ abandonPermissions ( ) {
103
+ PushNotification . abandonPermissions ( ) ;
104
+ }
101
105
}
Original file line number Diff line number Diff line change @@ -204,6 +204,11 @@ Notifications.localNotificationSchedule = function(details) {
204
204
}
205
205
} ;
206
206
207
+ /* Abandon Permissions */
208
+ Notifications . abandonPermissions = function ( ) {
209
+ this . handler . abandonPermissions ( ) ;
210
+ }
211
+
207
212
/* Internal Functions */
208
213
Notifications . _onRegister = function ( token ) {
209
214
if ( this . onRegister !== false ) {
@@ -331,10 +336,6 @@ Notifications.popInitialNotification = function(handler) {
331
336
} ) ;
332
337
} ;
333
338
334
- Notifications . abandonPermissions = function ( ) {
335
- return this . callNative ( 'abandonPermissions' , arguments ) ;
336
- } ;
337
-
338
339
Notifications . checkPermissions = function ( ) {
339
340
return this . callNative ( 'checkPermissions' , arguments ) ;
340
341
} ;
You can’t perform that action at this time.
0 commit comments