react-native-mixpanel icon indicating copy to clipboard operation
react-native-mixpanel copied to clipboard

Crash on clearPushRegistrationId()

Open lucasrocali opened this issue 6 years ago • 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)

lucasrocali avatar May 08 '18 13:05 lucasrocali

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

wkoutre avatar May 09 '18 18:05 wkoutre

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

cwhenderson20 avatar May 10 '18 18:05 cwhenderson20

Any update?

AdriaRios avatar Sep 05 '18 12:09 AdriaRios

Any plan on fixing this?

robertofrontado avatar Oct 12 '18 13:10 robertofrontado

Hey, any update?

Gazfay avatar Jan 16 '19 15:01 Gazfay

Same issue here.

sejas avatar Apr 24 '19 11:04 sejas

any chance to merge https://github.com/davodesign84/react-native-mixpanel/pull/192? @davodesign84

putuyoga avatar Aug 30 '19 02:08 putuyoga

+1

stvmachine avatar Oct 23 '19 03:10 stvmachine