首页 > 解决方案 > Firebase 通知在我自己的设备上不起作用

问题描述

我使用 JSON 通过 Firebase 向我的 android 应用程序发送通知。

我在我的 Android 设备中收到所有发送的通知,但没有其他用户的令牌在用户下没有收到它们。

发送通知的代码有问题吗?

def send_push (thedate):
    users = get_users()
    for i in xrange(len(users) / 1000 + 1):
        url = "https://fcm.googleapis.com/fcm/send"
        body = {
            "data": {
                "title": "{0} is available in {1}!!".format(thedate, book_name),
                "message": "New available books. Click here to open the booking site!",
                "type": "open_book",
                "click_action": "open_book",
                "book_id": book_id,
                "theDate": thedate,
                "url": "https://bookings.doc.govt.nz/Saturn/Facilities/SearchViewGW.aspx?placeId="+DOCtrekID
            },
            "registration_ids": users[i * 1000:((i + 1) * 1000 - 1)]
        }
        headers = {
            "Content-Type": "application/json",
            "Authorization": "key=***key***"
        }
        d = requests.post(url, data=json.dumps(body), headers=headers)
        print d
    print users

send_push("23/10/2018")

标签: jsonfirebase

解决方案


推荐阅读