[英]MixPanel Push Notification Not Received
我已经在MiXPanel控制台上设置了MixPanel Push Notification Documentation中提到的所有内容。 我只是在Google和MixPanel Docs上找到了Needfull,浪费了我的2天时间。
这是我的代码
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();
}
}
我使用的变量:
MIXPANEL_PROJECT_ID_TOKEN:我是从mixPanel ProjectSetting-> Management-> Token获得的。
PROJECT_NUMBER:来自google-service.json文件的project_number
注册接收器以获取推送通知。
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发送推送,但没有连接到设备。
如果我弄错了地方,请告诉我。
我已经解决了这个问题,现在我正在从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();
}
}
希望如果其他人遇到同样的问题,它将对他们有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.