davide-scalzo/react-native-mixpanel

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

DipanshKhandelwal opened this issue · 13 comments

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

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

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.

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

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 :)

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) #259

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.

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?

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

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

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 ?

Yeah, I did

Tried importing Mixpanel like this:
#import "react-native-mixpanel/Mixpanel.h"

and like this:
#import "Mixpanel/Mixpanel.h"

With same results

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