Firebaseクラウドメッセージングに問題があります: 2つの拡張サービスFirebaseInstanceIdServiceとFirebaseMessagingServiceを使用して小さなアプリケーションを実装しました。Firebaseクラウドメッセージング:いいえトークンと奇妙な通知動作
私がアプリケーションを起動し、 Firebaseコンソール経由で通知を送信すると、デバイス上で通知が届きます。 すべて動作します。 再度アプリケーションを開くと、アプリケーションがハングアップし、黒色の という画面が表示されます。 Android Studioコンソールには出力がありません。 Firebaseコンソールから2番目の通知も受け取りません。 次に、ダイアログが表示されます。「アプリケーションは反応しません」 もう一度アプリケーションを開くと、再び正常に機能します。
私はまた、Logcatでトークンを取得しない
Firebase InstanceIdService(?):
public class InstanceIdService extends FirebaseInstanceIdService
{
private static final String TAG = "InstanceIdService";
@Override
public void onTokenRefresh()
{
String token = FirebaseInstanceId.getInstance().getToken();
Log.e(TAG, "!!!!!!!!!!!!!!!!!! Got token: " + token);
}
}
FirebaseMessagingService:
public class MyFirebaseMessagingService extends FirebaseMessagingService
{
@Override
public void onMessageReceived(RemoteMessage remoteMessage)
{
sendNotification(remoteMessage);
}
public void sendNotification(RemoteMessage remoteMessage)
{
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle(remoteMessage.getFrom())
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
}
のAndroid Studioコンソールでのみエラーが です"モジュール記述子クラスを読み込めませんでした"が、既知のバグである です。
私があなたを助けてくれることを願っています。
よろしく、 フェリックス
EDIT:Firebaseコンソールからエラーメッセージ:(?)私もLogcatでトークンを取得しない
Exception java.lang.RuntimeException: Parcel [email protected]: Unmarshalling unknown type code 1936206469 at offset 68
android.os.Parcel.readValue (Parcel.java:2087)
android.os.Parcel.readArrayMapInternal (Parcel.java:2321)
android.os.Bundle.unparcel (Bundle.java:249)
android.os.Bundle.getString (Bundle.java:1118)
com.google.firebase.messaging.FirebaseMessagingService.zzT()
com.google.firebase.messaging.FirebaseMessagingService.zzm()
com.google.firebase.iid.zzb$2.run()
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:841)
ありがとう、私はトークンを持っています – Cyberlander
@Cyberlander修正は何ですか? – mboy