Skip to content

Instantly share code, notes, and snippets.

@fhrzn
Last active January 6, 2020 10:25
Show Gist options
  • Save fhrzn/e94041976f44fd3367d3bc5a56dc2f04 to your computer and use it in GitHub Desktop.
Save fhrzn/e94041976f44fd3367d3bc5a56dc2f04 to your computer and use it in GitHub Desktop.
public class FirebaseCloudMessagingService extends FirebaseMessagingService {
public String TAG = "FIREBASE MESSAGING";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getFrom());
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
startActivity(new Intent(this, NotifikasiActivity.class));
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
}
@Override
public void onNewToken(String s) {
super.onNewToken(s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment