Firebase通知无法正常运行我自己的设备

时间:2018-10-28 19:46:30

标签: json 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")

0 个答案:

没有答案