davide-scalzo / react-native-mixpanel

A React Native wrapper for Mixpanel tracking
MIT License
455 stars 195 forks source link

MIX_PANEL.showInAppMessageIfAvailable() throws "Unhandled promise rejection", ReferenceError : Can't find variable: token #256

Closed DipanshKhandelwal closed 3 years ago

DipanshKhandelwal commented 3 years ago

MIX_PANEL.showInAppMessageIfAvailable();

Every time I try to call this function, I face the following error.

Throws same error for Android and iOS

Error : "Unhandled promise rejection", ReferenceError : Can't find variable: token

Simulator Screen Shot - iPhone 11 Pro Max - 2020-09-07 at 10 00 39

IevgenRagulin commented 3 years ago

Would be awesome to have this merged. Right now showInAppMessageIfAvailable is unusable really:(

DipanshKhandelwal commented 3 years ago

I understand. It was a problem for my team as the inAppMessage was popping up at the time when things were still initialising. We're using a fork for now. Would be great to get it directly from the main repository.

IevgenRagulin commented 3 years ago

Do you have permissions to merge this? Or could @davodesign84 merge this please?

davide-scalzo commented 3 years ago

Done :) unfortunately I don't participate work anymore on react native and don't have the time to follow updates and such but a nice mention and at least a couple of people test it I'm happy to merge :)

IevgenRagulin commented 3 years ago

Thank you @davodesign84 ! Would you be able to also bump the version? I've submitted this pull request for version bump (not sure if that's helpful) https://github.com/davodesign84/react-native-mixpanel/pull/259

davide-scalzo commented 3 years ago

Yes, I'll do it when I get in front of the PC. Yolo merge on mobile 😬😂

Hopefully mixpanel will be able to open up their beta soon.

IevgenRagulin commented 3 years ago

Yeah, would be awesome to have an implementation from mixpanel @davodesign84 . Is there anything else that needs to be done to publish the change to npm or will github do this automatically?

IevgenRagulin commented 3 years ago

Nice, thanks @davodesign84 , I can see the new version in npm now

IevgenRagulin commented 3 years ago

@DipanshKhandelwal , the error is now gone, thank you for you PR. However, I keep getting the "autoshow" messages on ios. Do you remember if you had to do anything else to prevent "autoshow" on ios that's not mentioned in documentation? Do I need to remove this line from react native code perhaps?

Mixpanel.sharedInstanceWithToken(YOUR_PROJECT_TOKEN);

DipanshKhandelwal commented 3 years ago
Mixpanel *mixpanel = [Mixpanel sharedInstanceWithToken:YOUR_MIXPANEL_TOKEN];
mixpanel.showNotificationOnActive = NO;

Did you initialise it in iOS code ? And set the value of mixpanel.showNotificationOnActive as NO ?

IevgenRagulin commented 3 years ago

Yeah, I did

IevgenRagulin commented 3 years ago

Tried importing Mixpanel like this:

import "react-native-mixpanel/Mixpanel.h"

and like this:

import "Mixpanel/Mixpanel.h"

With same results

DipanshKhandelwal commented 3 years ago

No, I didn't do anything else apart from the native initialization and setting mixpanel.showNotificationOnActive as NO.