Guest User

Untitled

a guest
Mar 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. public class FcmMessagingService extends FirebaseMessagingService {
  2. private Map<String, String> data;
  3. private static final String TAG="MyFirebaseMsgService";
  4. @Override
  5. public void onMessageReceived(RemoteMessage remoteMessage) {
  6. super.onMessageReceived(remoteMessage);
  7. data=remoteMessage.getData();
  8. String message=data.get("message");
  9. String titledata=data.get("title");
  10. ManualNotification(titledata , message);
  11. }
  12. private void ManualNotification(String title , String messageBody){
  13. Intent intent = new Intent(this, MainActivity.class);
  14. Bundle bundle = new Bundle();
  15. bundle.putString("message", messageBody);
  16. intent.putExtras(bundle);
  17. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  18. PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
  19. Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.splash_img);
  20. Notification.BigPictureStyle bigpicture = new Notification.BigPictureStyle();
  21. bigpicture.bigPicture(bmp);
  22. NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
  23. .setSmallIcon(R.drawable.notifaction)
  24. .setContentTitle(title)
  25. //.setContentText(messageBody)
  26. .setLargeIcon(bmp)
  27. .setContentIntent(pendingIntent)
  28. .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
  29. .setContentText(messageBody).setLights(Color.YELLOW, 300, 300)
  30. .setVibrate(new long[] { 100, 250 })
  31. .setDefaults(Notification.DEFAULT_SOUND)
  32. .setAutoCancel(true);
  33. NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  34. notificationManager.notify(0, notificationBuilder.build());
  35. }
  36. }
Add Comment
Please, Sign In to add comment