Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

fix(push): Crash clearPushRegistrationId #192

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare module 'react-native-mixpanel' {
setPushRegistrationId(token: string): Promise<void>

// android only
clearPushRegistrationId(): Promise<void>
clearPushRegistrationId(token?: string): Promise<void>

reset(): Promise<void>
}
Expand Down Expand Up @@ -61,12 +61,12 @@ declare module 'react-native-mixpanel' {
setPushRegistrationId(token: string): void;

// android only
clearPushRegistrationId(): void;
clearPushRegistrationId(token?: string): void;

reset(): void;
}

const mixpanelApi: MixpanelAPI;
export default mixpanelApi;

}
}
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ export class MixpanelInstance {
}

// android only
clearPushRegistrationId(): Promise<void> {
clearPushRegistrationId(token?: string): Promise<void> {
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<void> {
Expand Down Expand Up @@ -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() {
Expand Down