如何从Android设备上的parse.com获取解析通知?
问题描述:
不工作的应用程序。如何从推送通知中解析数据?如何从Android设备上的parse.com获取解析通知?
我发送通知没有提示到android设备。
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo(\"device_id\", \"1234567890\"); // device_id created in parse.com
ParsePush push = new ParsePush();
push.setQuery(query);
push.setData(data);
push.sendInBackground(); // i see this notification in parse.com
,然后我写:
public MyCustomReceiver myReceiver = new MyCustomReceiver();
myReceiver.onReceive(this, getIntent());
类为接收:
public class MyCustomReceiver extends BroadcastReceiver {
private static final String TAG = \"MyCustomReceiver\";
@Override
public void onReceive(Context context, Intent intent) {
try {
String action = intent.getAction();
String channel = intent.getExtras().getString(\"org.xxx.xxx.Channel\");
JSONObject json = new JSONObject(intent.getExtras().getString("org.xxx.xxx.Data"));
Log.d(TAG, \"got action \" + action + \" on channel \" + channel + \" with:\");
Iterator itr = json.keys();
while (itr.hasNext()) {
String key = (String) itr.next();
Log.d(TAG, "..." + key + " => " + json.getString(key));
tv_n.setText(json.getString(key));
}
} catch (JSONException e) {
Log.d(TAG, "JSONException: " + e.getMessage());
}
}
}
清单:
<receiver android:name="com.xxx.MyCustomReceiver" android:exported="false">
<intent-filter>
<action android:name="com.xxx.UPDATE_STATUS" />
</intent-filter>
</receiver>
答
是否在parse.com上的“允许从客户端发送推送”中的“推送”选项卡中的项目设置中?
你添加自定义的接收器来体现?:
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="YOURPACKAJE.MyCustomReceiver "//its your this class should extends ParsePushBroadcastReceiver
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>
<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="YOURPACKAJE" />
</intent-filter>
</receiver>
也为更多信息看这个问题,我的答案Getting Parse Push Notification in List view