使用Firebase控制台发送通知时。我无法在Android P上收到通知。
我购买了一部适用于android pie的新手机。使用FCM发送通知时没有收到通知。
我在android O中遇到通知问题的代码。
public class NotificationHelper extends ContextWrapper {
private static final String XXXXXXX= "com.release.info.xxxxxx.xxxxxx";
private static final String XXXXXXXXX= "xxxxxxxx";
private NotificationManager notificationManager;
public NotificationHelper(Context base) {
super(base);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ;
createChannel();
}
@TargetApi(Build.VERSION_CODES.O)
private void createChannel() {
NotificationChannel XXXXXXXXXX= new NotificationChannel(XXXXXXX, XXXXXXXXXXX, NotificationManager.IMPORTANCE_DEFAULT);
XXXXXXX.enableLights(true);
XXXXXXX.enableVibration(true);
XXXXXXX.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
getManager().createNotificationChannel(xxxxxxxxChannel);
}
public NotificationManager getManager() {
if (notificationManager == null)
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
return notificationManager;
}
@TargetApi(Build.VERSION_CODES.O)
public Notification.Builder getXXXXXXXXNotification (String title,
String description,
String url,
String code,
String id,
String actual_price,
String deal_price,
String key,
Uri SoundUri)
{
return new Notification.Builder(getApplicationContext(), xxxxxxxxx)
.setContentText(title)
.setSmallIcon(R.drawable.app_logo)
.setSound(SoundUri)
.setAutoCancel(true);
}
}