Open activity by clicking on the push notification from Parse

前端 未结 4 1075
抹茶落季
抹茶落季 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 07:09

    You should override onPushOpen(...) method in your receiver class:

    import com.parse.ParsePushBroadcastReceiver;
    
    public class PushIntentReceiver extends ParsePushBroadcastReceiver {
    
        @Override
        protected void onPushOpen(Context context, Intent intent) {
            JSONObject pushData = null;
    
            try {
                pushData = new JSONObject(intent.getStringExtra(KEY_PUSH_DATA));            
                Intent pushIntent = new Intent(context, YourActivity.class);        
                pushIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                pushIntent.putExtra("store", pushData.getString("data"));
                context.startActivity(pushIntent);
    
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
    

提交回复
热议问题