Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FcmMessagingService extends FirebaseMessagingService {
- private Map<String, String> data;
- private static final String TAG="MyFirebaseMsgService";
- @Override
- public void onMessageReceived(RemoteMessage remoteMessage) {
- super.onMessageReceived(remoteMessage);
- data=remoteMessage.getData();
- String message=data.get("message");
- String titledata=data.get("title");
- ManualNotification(titledata , message);
- }
- private void ManualNotification(String title , String messageBody){
- Intent intent = new Intent(this, MainActivity.class);
- Bundle bundle = new Bundle();
- bundle.putString("message", messageBody);
- intent.putExtras(bundle);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
- Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.splash_img);
- Notification.BigPictureStyle bigpicture = new Notification.BigPictureStyle();
- bigpicture.bigPicture(bmp);
- NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.notifaction)
- .setContentTitle(title)
- //.setContentText(messageBody)
- .setLargeIcon(bmp)
- .setContentIntent(pendingIntent)
- .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
- .setContentText(messageBody).setLights(Color.YELLOW, 300, 300)
- .setVibrate(new long[] { 100, 250 })
- .setDefaults(Notification.DEFAULT_SOUND)
- .setAutoCancel(true);
- NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(0, notificationBuilder.build());
- }
- }
Add Comment
Please, Sign In to add comment