diff --git a/android/src/main/java/com/kevinejohn/RNMixpanel/RNMixpanelModule.java b/android/src/main/java/com/kevinejohn/RNMixpanel/RNMixpanelModule.java index bbb8f01..6191cad 100644 --- a/android/src/main/java/com/kevinejohn/RNMixpanel/RNMixpanelModule.java +++ b/android/src/main/java/com/kevinejohn/RNMixpanel/RNMixpanelModule.java @@ -304,10 +304,14 @@ public void setPushRegistrationId(final String token, final String apiToken, Pro // Android only @ReactMethod - public void clearPushRegistrationId(final String apiToken, Promise promise) { + public void clearPushRegistrationId(final String apiToken, String registrationId, Promise promise) { final MixpanelAPI instance = getInstance(apiToken); synchronized(instance) { - instance.getPeople().clearPushRegistrationId(); + if (registrationId == null) { + instance.getPeople().clearPushRegistrationId(); + } else { + instance.getPeople().clearPushRegistrationId(registrationId); + } } promise.resolve(null); } diff --git a/index.d.ts b/index.d.ts index 90cc399..8f06886 100644 --- a/index.d.ts +++ b/index.d.ts @@ -28,7 +28,7 @@ declare module 'react-native-mixpanel' { setPushRegistrationId(token: string): Promise // android only - clearPushRegistrationId(): Promise + clearPushRegistrationId(token?: string): Promise reset(): Promise } @@ -61,7 +61,7 @@ declare module 'react-native-mixpanel' { setPushRegistrationId(token: string): void; // android only - clearPushRegistrationId(): void; + clearPushRegistrationId(token?: string): void; reset(): void; } @@ -69,4 +69,4 @@ declare module 'react-native-mixpanel' { const mixpanelApi: MixpanelAPI; export default mixpanelApi; -} \ No newline at end of file +} diff --git a/index.js b/index.js index c3c5865..3ee7e14 100644 --- a/index.js +++ b/index.js @@ -180,11 +180,11 @@ export class MixpanelInstance { } // android only - clearPushRegistrationId(): Promise { + clearPushRegistrationId(token?: string): Promise { if (!this.initialized) throw new Error(uninitializedError('clearPushRegistrationId')) if (!RNMixpanel.clearPushRegistrationId) throw new Error('No native implementation for setPusclearPushRegistrationIdhRegistrationId. This is Android only.') - return RNMixpanel.clearPushRegistrationId() + return RNMixpanel.clearPushRegistrationId(this.apiToken, token || null) } reset(): Promise { @@ -367,10 +367,10 @@ export default { }, // android only - clearPushRegistrationId() { + clearPushRegistrationId(token?: string) { if (!defaultInstance) throw new Error(NO_INSTANCE_ERROR) - defaultInstance.clearPushRegistrationId() + defaultInstance.clearPushRegistrationId(token || null) }, reset() {