我在Python应用程序中使用FCM向Android应用程序发送消息。一切似乎都正常,发送消息返回成功,但不要调用需要接收消息的onMessageReceived()。
{'multicast_ids': [4032469777984266672], 'success': 1, 'failure': 0, 'canonical_ids': 0, 'results': [{'message_id': '0:1647775893746697%207ea77df9fd7ecd'}], 'topic_message_id': None}Andriod应用程序中的onMessageReceived()从未被调用过,我不知道为什么.一切看起来都很好..。
,有什么问题吗?
我的Python代码:
import time
from pyfcm import FCMNotification
push_service = FCMNotification(api_key="AAAArIgWtH8:APA91bHIwFuE9-OGq3c8xWGUBL2hbsCd2ZEIn9fIWv9m_rBOZ1wiP1rjbNdTT12jaBQ8miqYxWpSoNVF_v4D4kdgeJFDRYvaYav6PmoOqbCVy1bqfx8sNCMEaL6n0g0lUwjNdXiqOZv9")
mToken = "dCKDAQ4xSmyT-eGe1B348L:APA91bElsno4aLHrqIRysHqWUVsNvkq86KQiQNeUG9W6O9WCKcX38gmDyxHIF6XB4CC0G4XNwKdciRQV_KxCl-hsaP1GOOT9_38FPlkXj6irwOMF1HnJNYk3bbfMvulD9Qz_pOXTvQHC"
nth = 0
def sendMessage(p):
global nth
nth += 1
registration_id = mToken
data_message = {
"body" : str(nth) + " : test M"
}
result = push_service.single_device_data_message(registration_id=registration_id, data_message=data_message)
print(result)
def _main():
while True:
sendMessage(80)
time.sleep(60 * 1)
if __name__ == "__main__":
_main()发布于 2022-03-20 12:34:36
简单地说,如果您的python代码正确地触发了FCM,那么您应该在您配置为侦听的地方获得消息,而在您的情况下,这不是场景。
因此,海事组织,你可以做的一个可能的检查是在你的安卓应用程序中的Firebase SDK设置。如果操作不正确,即使后端代码能够调用FCM,FCM服务器也会部署消息/notification(S),但是应用程序不会仅仅捕获它。
https://stackoverflow.com/questions/71546630
复制相似问题