[英]How to get parse notification from parse.com on android device?
无法正常运行的应用。 如何从推送通知获取解析数据?
我向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>
还需要更多信息,请参阅此问题和我的答案在列表视图中获取解析推送通知
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.