【问题标题】:Parse.com: Get Pushnotification Message on onPushOpenParse.com:在 onPushOpen 上获取 Pushnotification 消息
【发布时间】:2014-12-26 22:51:32
【问题描述】:

在我的 android 应用程序中,我使用 Parse.com 提供的推送通知。我已经成功完成了这项工作,但是我的应用程序有多个推送通知,并且应该根据按下的推送通知加载不同的活动。我希望能够从 onPushOpen 的 intent 参数中获取推送通知的消息,但它似乎是空的? .有谁知道我如何在 onPushOpen 方法中获取消息?

对于某些情况,我在下面添加了我当前的自定义 PushReceiver 代码。

public class PushReceiver extends ParsePushBroadcastReceiver {

    @Override
    public void onPushOpen(Context context, Intent intent) {
        Log.e("Push", "Clicked");
        Intent i = new Intent(context, Splash.class);
        i.putExtras(intent.getExtras());
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }
}

谢谢。

【问题讨论】:

    标签: android parse-platform push-notification


    【解决方案1】:

    确保您已升级到 Parse-1.8.2。

    那么你还需要做两件事。

    1. 将信息添加到您的 AndroidManifest.xml(在 内)

      <service android:name="com.parse.PushService" />
      <receiver android:name="com.parse.GcmBroadcastReceiver" 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...ADD_PACKAGE_INFO_HERE..." />
          </intent-filter>
      </receiver>
      
      <receiver android:name="com..ADD_PACKAGE_INFO_HERE....PushReceiver"
                android:exported="false">
          <intent-filter>
              <action android:name="com.parse.push.intent.RECEIVE" />
              <action android:name="com.parse.push.intent.DELETE" />
              <action android:name="com.parse.push.intent.OPEN" />
          </intent-filter>
      </receiver>
      
    2. 将此添加到标签外的 AndroidManifest.xml

    3. 在 Parse.com 上的云代码中,将广播的 uri 设置为“com....ADD_PACKAGE_INFO_HERE...PushReceiver”

    注意:当您运行 Android 应用程序时,应在调试跟踪中为您提供 #1 和 #2。

    希望这会有所帮助。我花了几个小时试图让它工作,对我来说关键是更新到 1.8.2。

    编辑: 您还应该查看覆盖 onReceive 以及 onPushOpen ...实际上在通知上被调用。祝你好运。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-09
      • 1970-01-01
      • 2013-01-11
      • 1970-01-01
      • 2016-06-27
      • 1970-01-01
      相关资源
      最近更新 更多