I managed to send notification message from PHP file and send to mobile phone using Firebase Cloud Messaging (FCM).
Once the user click on the notification message on mo
// in service file
private void sendNotification(String messageBody) {
Intent intent = new Intent(this, MainActivity.class);
Log.d("Send","msg" +messageBody);
Toast.makeText(getApplicationContext(),"msg" +messageBody ,Toast.LENGTH_SHORT );
intent.putExtra("msg",messageBody);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Firebase Push Notification")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
// in Activity
Intent intent = getIntent();
String text = intent.getStringExtra("msg");
Log.d("Received","msg" +text);
Toast.makeText(getApplicationContext(),"Received" + text ,Toast.LENGTH_SHORT );