簡體   English   中英

如何在Android設備上從parse.com獲取解析通知?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM