Android O 에뮬레이터를 사용 중이며 Firebase 콘솔에서 알림을 받고 싶습니다. Android O를 제외한 모든 기기에서 정상적으로 작동합니다. 로그에이 오류가 표시됩니다.Android O에서 Firebase 알림이 작동하지 않습니다
W/Notification: Use of stream types is deprecated for operations other than volume control
W/Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
나는 채널 ID를 지정해야한다는 것을 알고 있습니다. 는 지금까지
의 AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/attach" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="my_notification_channel" />
<service android:name=".Helper.FirebaseIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name=".Helper.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<my all activities...>
했을 그래서 나는 또한 그래서이 모든 일을 한 후이
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "FCM Service";
private static final int NOTIFICATION_ID = 1;
private static final String NOTIFICATION_CHANNEL_ID = "my_notification_channel";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_DEFAULT);
// Configure the notification channel.
notificationChannel.setDescription("Channel description");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
}
NotificationCompat.Builder mBuilder;
mBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Title")
.setContentText(remoteMessage.getNotification().getBody())
.setOngoing(true)
.setChannelId(NOTIFICATION_CHANNEL_ID);
notificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
}
처럼 에 FirebaseMessagingService을 채널 ID를 지정했습니다. 나는 여전히 로그에서 오류 메시지를 받았고 console.Any 도움말에서 알림을받을 수 없습니다.
downvoting 뒤에 어떤 이유? –
메시지가 수신되었다는 것을 나타내는 '보낸 사람 :'로그 메시지가 보입니까? –
앱이 전경에있을 때 나는 그것을 볼 수 있습니다. 앱이 배경으로 돌아간 후에 오류 @ BobSnyder –