0
我試圖通過FCM傳遞「徽章」數字。 我知道onMessageReceived()時,只被調用: [有效載荷只包含「數據」,沒有消息]Firebase onMessageReceived()未通過pyfcm調用
我使用「com.google.firebase:火力的消息:11.0.2」 和pyfcm在服務器端發送我的通知。
result = push_service.notify_multiple_devices(
registration_ids=ids, data_message={'badge': '5'}
)
>> all success.
我的服務:
<service android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service
android:name=".MyFCMService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
我已閱讀this,但我不關閉應用程序(只需按HOME) 但:
public class MyFCMService extends FirebaseMessagingService {
private static final String TAG = "MyFCMService";
public MyFCMService() {
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, remoteMessage.getData().toString());
super.onMessageReceived(remoteMessage);
}
}
我在manifest.xml文件服務仍然,logcat(詳細)不顯示任何內容。 有什麼可能的原因嗎?
您應該首先使用FCM控制檯確認您的Android代碼。如果它工作正常後,你可以檢查你的後端。 –
我可以從FCM作曲家那裏得到這些消息。 – Wesely