簡體   English   中英

android-如何獲取解析推送通知發送的json數據

[英]android-How to get json data sent by parse push notification

我正在使用parse.com發送推送通知。它工作正常。

我想通過parse.com發送此json數據:

{"channel":"game","data":{ "alert":"Red Sox win 7-0!"}}

這是我的主要活動:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ParseAnalytics.trackAppOpened(getIntent());

    // inform the Parse Cloud that it is ready for notifications
    PushService.setDefaultPushCallback(this, MainActivity.class);
    ParseInstallation.getCurrentInstallation().saveInBackground();

}

1-如何獲取此json數據?

2-我發送了json數據,如何禁用通知? 當應用程序獲取json時,將顯示一條通知,並說“ parse push notification”。 如果我正在發送json數據,如何禁用此通知?

問題是如何在android中獲取此json?

您將獲得Json通知數據:

   try {
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        String jsonData = extras.getString("com.parse.Data");

        Log.v("Pares Data", jsonData);
        JSONObject jobj = new JSONObject(jsonData);=
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (JSONException e) {
    e.printStackTrace(); 

來源可以在這里找到

按照Parse自己的教程中所述,設置“ title” json條目為

(僅限Android,Windows 8和Windows Phone 8)在Android系統托盤或Windows 8烤面包通知中顯示的值。

{"channel":"game","data":{ "alert":"Red Sox win 7-0!","title":"INSERT TITLE HERE"}}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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