尽管在Django应用中成功回调,但FCM消息未在任何浏览器中显示

时间:2019-07-18 12:17:03

标签: python django firebase google-chrome firebase-cloud-messaging

我正在尝试从我的Django应用发送带有Firebase的推送。这是发送代码:

class Command(BaseCommand):
def handle(self, *args, **options):
    print('entered command')

    server_key = '<server-key>'

    token_id = '<token-id>'

    title = 'test push not'
    text = 'here is about how cool we are'
    icon = ''
    link = 'http://test.ru'


    url = 'https://fcm.googleapis.com/fcm/send'

    data = {
        "notification":{
            'title': title,
            'body': text,
            'icon': icon,
            'click_action': link
        },
        'to': token_id,
    }

    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'key={server_key}'
        }


    r = requests.post(url, data=json.dumps(data), headers=headers)
    print(r.text)
    print('message posted')

发送后,我收到了来自Firebase的回叫:

{"multicast_id":<multicast_id>,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"<message_id>"}]}

但是什么也没出现。我用手机在不同的PC,浏览器上尝试了此操作,但始终成功并且没有通知。已经在另一个firebase应用程序中使用了此测试脚本,并且效果很好。现在,除了服务器密钥外,我没有进行任何更改。我在新应用上再次注册了设备,但没有任何效果。

实际上我检查了this question,但仍然没有答案,同样的问题。

0 个答案:

没有答案