Reputation: 89
This is my code: showing error in this code
getString(R.string.default_notification_channel_id))
this is full code :
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
String messageTitle = remoteMessage.getNotification().getTitle();
String messageBody = remoteMessage.getNotification().getBody();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, getString(R.string.default_notification_channel_id))
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(messageTitle)
.setContentText(messageBody)
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
int mNotificationId = (int) System.currentTimeMillis();
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.notify(mNotificationId,mBuilder.build());
}
}
Upvotes: 1
Views: 4468
Reputation: 246
use Notification instead of NotificationCompact eg:
Notification.Builder mBuilder = new Notification.Builder(this, getString(R.string.default_notification_channel_id))
Upvotes: 1
Reputation: 1936
From the doc https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html i can see that new NotificationCompat.Builder
take as paramater context
and string
, you are giving this
and String
, this
referes to com.google.firebase.messaging.FirebaseMessagingService
not to a context
in your case.
Upvotes: 0