0
特定のfcmトークン(ユーザごと)で完全に動作します。今、私は「トピック」の通知を追加したいので、私は、サブスクリプションを追加しました:通知のこの種は処理しませんAndroid:Firebaseの "topics"通知が私のアプリケーションで処理されない
public class MyInstanceIDListenerService extends FirebaseInstanceIdService {
private static final String TAG = LogUtils.makeLogTag(MyInstanceIDListenerService.class);
/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. Note that this is also called
* when the InstanceID token is initially generated, so this is where
* you retrieve the token.
*/
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
LogUtils.LOGD(TAG, "Refreshed FCM token: " + refreshedToken);
...
subscribeTopics();
}
/**
* Subscribe to any FCM topics of interest, as defined by the TOPICS constant.
*/
private void subscribeTopics() {
for (String topic : MyFcmListenerService.TOPICS) {
FirebaseMessaging.getInstance().subscribeToTopic(topic);
}
}
}
そして、私の受信機では:
public class MyFcmListenerService extends FirebaseMessagingService {
private static final String TAG = LogUtils.makeLogTag(MyFcmListenerService.class);
// Topics
public static final String TOPIC = "/topics/";
public static final String UPGRADE = "upgrade";
public static final String[] TOPICS = {UPGRADE};
// Downstream type messages
public static final String PROFIL = "profil";
...
protected WebServicesModule getWebServicesModule() {
return MyApplication.getInstance().getDataHolder().getWebServicesModule();
}
public MyFcmListenerService() {
}
/**
* Called when message is received.
*
* @param message
*/
@Override
public void onMessageReceived(RemoteMessage message) {
String from = message.getFrom();
Map data = message.getData();
LogUtils.LOGD(TAG, "[FCM] Topic message received from [" + from + "]");
...
onMessageReceived機能()されます私は(ポストマンから)この通知を送信するときに呼び出されることはありません:このヘッダ構成と
:
ありがとうございました!