2016-06-22 8 views
3

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) 

答えて

3

onTokenRefresh()メソッドは、新しいトークンを生成するときに呼び出されます。アプリを開くたびに呼び出されることはありません。あなたは、私がアプリケーションを起動し、Firebaseコンソール経由で通知を送信する場合、私は私のデバイスで通知を受け取るFirebaseInstanceId.getInstance().getToken();

を使用してトークンを取得することができますしかし、 。すべてが機能します。私は再びアプリケーションを開くと、それがハングアップし、黒い画面が生成されます。

私は同様の問題に直面しました。これは一般的に、インターネットに接続していないか、遅い場合に発生します。解決策はまだありません。 :

+1

ありがとう、私はトークンを持っています – Cyberlander

+0

@Cyber​​lander修正は何ですか? – mboy

関連する問題