davide-scalzo/react-native-mixpanel

Crash on clearPushRegistrationId()

Opened this issue · 8 comments

The method clearPushRegistrationId() is getting the following error:
RNMixpanel.clearPushRegistrationId got 2 arguments, expected 3
The reason may be because the native method expects the apiToken

@ReactMethod
    public void clearPushRegistrationId(final String apiToken, Promise promise) {
        final MixpanelAPI instance = getInstance(apiToken);
        synchronized(instance) {
            instance.getPeople().clearPushRegistrationId();
        }
        promise.resolve(null);
    }

But the index.js does not sends it

clearPushRegistrationId(): 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()
  }

The solution may be simple, just add the apiToken on the method, just like most of the other methods do
return RNMixpanel.clearPushRegistrationId(this.apiToken)

+1 for this bug, same logs and output as expressed in OP.

Also +1 for the recommended solution: return RNMixpanel.clearPushRegistrationId(this.apiToken) in the root index.js of the project. Confirmed to work on my project.

To expand on this, it seems like the clearPushRegistrationId method in the native Android library (documentation) accepts either zero or one arguments. If the method is called with zero arguments, all push registration ids are cleared; if the method is called with one argument, a push registration id, only that one is cleared.

It's likely, then, that the JS method signature should be:

Mixpanel.clearPushRegistrationId(id?: string)

and the Android method should accept an additional argument:

@ReactMethod
public void clearPushRegistrationId(final String registrationId, final String apiToken, Promise promise)
    final MixpanelAPI instance = getInstance(apiToken);
    synchronized(instance) {
        instance.getPeople().clearPushRegistrationId(registrationId);
    }
    promise.resolve(null);
}

Any update?

Any plan on fixing this?

Hey, any update?

sejas commented

Same issue here.

any chance to merge #192? @davodesign84