Open activity by clicking on the push notification from Parse

前端 未结 4 1074
抹茶落季
抹茶落季 2021-02-14 06:29

I want to receive a push notification from Parse and open an List activity and use intent.putextra(\"dataFromParse\") before starting the activity. I\'m able to receive the push

4条回答
  •  孤街浪徒
    2021-02-14 06:54

    Solved it, having default activity as MainActivity, but checking the intent, and if there is something in "com.parse.Data" I will start a new intent.

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    String jsonData = extras.getString("com.parse.Data");
    JSONObject json = new JSONObject(jsonData);
    String pushStore = json.getString("data");
    if(pushStore!=null) {
        Intent pushIntent = new Intent();
        pushIntent.setClassName(MainActivity.this, "package.name.List");
        pushIntent.putExtra("store", pushStore);
        startActivity(pushIntent);
    }           
    

    Then just send a push with json: { "alert" : "Test", "data" : "store1" }

    @arvindwill Hope this will help.

提交回复
热议问题