I have an android application. In that i have a using Firebase for push notifications. I need to show a popup message in my home page when receive a message in FirebaseMessagingService
class
FirebaseMessagingService
String actiondata = remoteMessage.getData().get("action");
if(actiondata.equals("booking")){
Intent myIntent = new Intent("com.driver.approverequest");
myIntent.putExtra("contentdata",contentdata);
myIntent.putExtra("requestid",productId);
this.sendBroadcast(myIntent);
Log.d(TAG, "Message data : athira send " + message);
}
HomeActivity
public BroadcastReceiver myReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getStringExtra("action");
try {
JSONObject mJsonObject = new JSONObject(intent.getExtras().getString("contentdata"));
Log.d("hi...........",intent.getExtras().getString("contentdata"));
Toast.makeText(getApplicationContext(),"hi",Toast.LENGTH_LONG).show();
StartTrackingDriver();
} catch (Exception e){
}
}
};
@Override
protected void onResume() {
super.onResume();
registerReceiver(myReceiver, new IntentFilter("com.driver.approverequest"));
}
@Override
protected void onPause() {
super.onPause();
try {
unregisterReceiver(myReceiver);
}catch (Exception e){}
}