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

Crash on clearPushRegistrationId() #134

Open
lucasrocali opened this issue May 8, 2018 · 8 comments
Open

Crash on clearPushRegistrationId() #134

lucasrocali opened this issue May 8, 2018 · 8 comments

Comments

@lucasrocali
Copy link

lucasrocali commented May 8, 2018

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)

@wkoutre
Copy link
Contributor

wkoutre commented May 9, 2018

+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.

@cwhenderson20
Copy link

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);
}

@AdriaRios
Copy link

Any update?

@robertofrontado
Copy link

Any plan on fixing this?

@Gazfay
Copy link

Gazfay commented Jan 16, 2019

Hey, any update?

@sejas
Copy link

sejas commented Apr 24, 2019

Same issue here.

@putuyoga
Copy link

any chance to merge #192? @davodesign84

@stvmachine
Copy link

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants