From e6cb5fed606f0ca248555f18bc31c55a41171a89 Mon Sep 17 00:00:00 2001 From: Michele Bombardi Date: Tue, 26 Sep 2017 16:33:20 +0200 Subject: [PATCH] deleteInstanceId feature (Android only) --- .../firebase/messaging/RNFirebaseMessaging.java | 11 +++++++++++ index.d.ts | 4 ++++ lib/modules/messaging/index.js | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java index 261a4dee..1b3856d3 100644 --- a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java +++ b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java @@ -72,6 +72,17 @@ public class RNFirebaseMessaging extends ReactContextBaseJavaModule implements L promise.resolve(FirebaseInstanceId.getInstance().getToken()); } + @ReactMethod + public void deleteInstanceId(Promise promise){ + try { + FirebaseInstanceId.getInstance().deleteInstanceId(); + promise.resolve(null); + } catch (IOException e) { + e.printStackTrace(); + promise.reject(null, e.getMessage()); + } + } + @ReactMethod public void createLocalNotification(ReadableMap details) { Bundle bundle = Arguments.toBundle(details); diff --git a/index.d.ts b/index.d.ts index e2f0c29f..057d68c0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -608,6 +608,10 @@ declare module "react-native-firebase" { * This token can be used in the Firebase console to send messages to directly. */ getToken(forceRefresh?: Boolean): Promise + /** + * Reset Instance ID and revokes all tokens. + */ + deleteInstanceId(): Promise /** * On the event a devices FCM token is refreshed by Google, * the new token is returned in a callback listener. diff --git a/lib/modules/messaging/index.js b/lib/modules/messaging/index.js index 64307d9e..3e72505b 100644 --- a/lib/modules/messaging/index.js +++ b/lib/modules/messaging/index.js @@ -109,6 +109,14 @@ export default class Messaging extends ModuleBase { return this._native.getToken(); } + /** + * Reset Instance ID and revokes all tokens. + * @returns {*|Promise.<*>} + */ + deleteInstanceId() { + return this._native.deleteInstanceId(); + } + /** * Create and display a local notification * @param notification