Created
November 1, 2019 01:40
-
-
Save BurningDroid/547c9cf918ace81b51fd1e810bd7b0b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FCMService extends FirebaseMessagingService { | |
public FCMService() { | |
} | |
@Override | |
public void onMessageReceived(RemoteMessage remoteMessage) { | |
super.onMessageReceived(remoteMessage); | |
if (remoteMessage.getData().size() > 0) { | |
sendNotification(remoteMessage.getData()); | |
} | |
} | |
private void sendNotification(Map<String, String> messageMap) { | |
String recruitId = messageMap.get("recruitId"); | |
String body = messageMap.get("body"); | |
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); | |
NotificationCompat.Builder notificationBuilder = | |
new NotificationCompat.Builder(this) | |
.setSmallIcon(R.drawable.ic_user_add) | |
.setContentTitle("FCM Message") | |
.setContentText(body) | |
.setAutoCancel(true) | |
.setSound(defaultSoundUri) | |
NotificationManager notificationManager = | |
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | |
notificationManager.notify(0, notificationBuilder.build()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment