我已经在MiXPanel控制台上设置了MixPanel推送通知文档上提到的所有内容。我只是浪费了我的两天,因为我发现需要在谷歌和MixPanel文档。
这里是我的代码
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();
}
}我使用了以下变量:
注册接收器,以获得推送通知。
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>将标识发送到段。(此处添加了设备令牌)
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);我通过选择用户发送来自MixPanel的推送,而不是进入设备。
如果我弄错了,请告诉我。
发布于 2017-12-16 13:32:27
我已经解决了这个问题,现在我得到了MixPanel的推动:
我刚刚删除了方法中不必要的方法调用(InitMixPanelForPush)。
更新方法是
private void initMixPanelForPush() {
try
{
MixpanelAPI mMixpanel = MixpanelAPI.getInstance(this, ConstantsLib.MIXPANEL_PROJECT_ID_TOKEN);
mMixpanel.identify(AppSharedPrefs.getInstance(context).getUserId());
mMixpanel.getPeople().identify(AppSharedPrefs.getInstance(context).getUserId());
mMixpanel.getPeople().initPushHandling(ConstantsLib.PROJECT_NUMBER);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}希望它能帮助其他人,如果他们遇到同样的问题。
https://stackoverflow.com/questions/47829231
复制相似问题