Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit a06d7d5

Browse files
committed
Put deleteInstanceId() in a separate thread.
1 parent 808d922 commit a06d7d5

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,16 @@ public void removeDeliveredNotifications(ReadableArray identifiers) {
265265
* Unregister for all remote notifications received
266266
*/
267267
public void abandonPermissions() {
268-
try {
269-
FirebaseInstanceId.getInstance().deleteInstanceId();
270-
} catch (IOException e) {
271-
Log.e(LOG_TAG, "exception", e);
272-
return;
273-
}
268+
new Thread(new Runnable() {
269+
@Override
270+
public void run() {
271+
try {
272+
FirebaseInstanceId.getInstance().deleteInstanceId();
273+
Log.i(LOG_TAG, "InstanceID deleted");
274+
} catch (IOException e) {
275+
Log.e(LOG_TAG, "exception", e);
276+
}
277+
}
278+
}).start();
274279
}
275280
}

component/index.android.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ NotificationsComponent.prototype.removeDeliveredNotifications = function(identif
127127
RNPushNotification.removeDeliveredNotifications(identifiers);
128128
}
129129

130+
NotificationsComponent.prototype.abandonPermissions = function() {
131+
RNPushNotification.abandonPermissions();
132+
}
133+
130134
module.exports = {
131135
state: false,
132136
component: new NotificationsComponent()

example/App.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ export default class App extends Component {
102102
style={styles.button}
103103
onPress={() => {
104104
this.notif.abandonPermissions();
105-
Alert.alert(
106-
'Abandon Permissions',
107-
'Reload the app to register again with a new token'
108-
);
109105
}}>
110106
<Text>Abandon Permissions</Text>
111107
</TouchableOpacity>

0 commit comments

Comments
 (0)