davide-scalzo / react-native-mixpanel

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

Push Notification on android #181

Closed yjose closed 5 years ago

yjose commented 5 years ago

Hi @davodesign84, thanks for the great work 👍 I am trying to make push notification work for my react-native app. My push notifications work like a charm on ios but on Android, I have an issue. I am using react-native-push-notification to get device token to be sent using Mixpanel.addPushDeviceToken(token). but the problem is I am only receiving a silent notification on my app when I use the mixpanel UI to send push notification which not the case when I am using third-party service to test push notification like PushWatchwith. lets me know if you need more details

YahiaJabeur commented 5 years ago

Hi @yjose Push notification works fine with me on android without using react-native-push-notification and without sending token Mixpanel.addPushDeviceToken(token) I m just creating a profile with function import DeviceInfo from 'react-native-device-info'; const deviceId = DeviceInfo.getDeviceId(); Mixpanel.identify(deviceId);

yjose commented 5 years ago

Adding this to the AndroidManifest.xml file fix my issue

<receiver android:name="com.mixpanel.android.mpmetrics.GCMReceiver"
                  android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.myname.myapp" /> <!-- <-- replace with your package name  -->
            </intent-filter>
        </receiver>
MoeMamdouh commented 4 years ago

@yjose its crashs and return

Unable to instantiate receiver com.mixpanel.android.mpmetrics.GCMReceiver: 
java.lang.ClassNotFoundException: Didn't find class "com.mixpanel.android.mpmetrics.GCMReceiver"
 on path: DexPathList