I Have setup all the things on MiXPanel console that is mention on MixPanel Push Notification Documentation. I just wasted my 2 days by finding needfull on google and also on MixPanel Docs.
Here is my Code
private void initMixPanelForPush() {
try
{
MixpanelAPI mMixpanel = MixpanelAPI.getInstance(this, ConstantsLib.MIXPANEL_PROJECT_ID_TOKEN);
MixpanelAPI.People people = mMixpanel.getPeople();
people.initPushHandling(ConstantsLib.PROJECT_NUMBER);
people.identify(AppSharedPrefs.getInstance(context).getUserId());
people.setPushRegistrationId(AppSharedPrefs.getInstance(context).getDeviceToken());
people.showNotificationIfAvailable(this);
AppController.getInstance().getAnalyticInstance().getAnalyticsContext().putDeviceToken(AppSharedPrefs.getInstance(context).getDeviceToken());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
Variable I have used:
MIXPANEL_PROJECT_ID_TOKEN: I obtained it from mixPanel ProjectSetting->Management->Token.
PROJECT_NUMBER: project_number from google-service.json file
Registering Receiver for getting push notification.
AndroidManifest.xml
<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="my_package _name" />
</intent-filter>
</receiver>
Sending Identity to segment. (Device token is added here)
Traits traits = new Traits();
traits.putName(basicDetails.getFullName());
traits.putEmail(basicDetails.getContactEmail());
traits.putPhone(basicDetails.getContactNumber());
traits.putValue("userId", basicDetails.getUserId());
traits.putValue("android_devices", AppSharedPrefs.getInstance(context).getDeviceToken());
getAnalyticInstance().identify(AppSharedPrefs.getInstance(this).getUserId(), traits, null);
I am sending push from MixPanel by selecting users, but not getting on device.
Please let me know if somewhere I mistaken.
I have resolved this issue, now I am getting push from MixPanel:
I have just remove un-necessary methods call in the method(initMixPanelForPush)
Updated method is
Hope it will help others if they are getting same issue.