未收到MixPanel推送通知

问题描述 投票:1回答:1

我已经在MixPanel Push Notification Documentation上提到的MiXPanel控制台上设置了所有内容。我只是在谷歌和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

注册Receiver以获取推送通知。

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发送推送,但没有进入设备。

如果我弄错了,请告诉我。

android push-notification mixpanel segment-analytics
1个回答
2
投票

我已经解决了这个问题,现在我从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();
    }
}

希望如果他们遇到同样的问题,它会帮助别人。

© www.soinside.com 2019 - 2024. All rights reserved.