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")
解决方案
推荐阅读
- r - R中的Matlab函数uint8
- node.js - 使用 Selenium 的 AWS Lambda Nodejs 12.x:找不到 Chrome 驱动程序
- android - withContext(Dispatchers.Main) 中的代码块未运行
- api - 将类变量传递给 API 函数
- sql-server - 在 PowerShell 中将字符串拆分为单独的字符串
- java - Android preform 预编译优化
- flutter - 颤振按钮不会在点击时更新任何内容
- ruby-on-rails - 如何检查关联模型
- python - 如何使用 Django 将 html 文件链接在一起?
- powershell - 如何仅使用带有 openssl 的公共证书验证文件签名?