python - 推送通知不适用于推送通知时间
问题描述
当我在 python 中使用推送通知时,我无法按要求发送推送通知时间
示例:1m 或 60m 等
我在应用程序中使用https://github.com/olucurious/PyFCM这个。
请举例说明如何根据需要发送推送通知时间
registration_id = request.POST['registration_id']
message_title = request.POST['message_title']
message_body = request.POST['message_body']
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)
我们需要在哪里发送此应用程序的推送通知类型当我设置时间时,会遇到很多问题,并且示例不会在整个示例中退出。
完整示例:
def index(request):
if (request.POST['type'] == 'android'):
push_service = FCMNotification(api_key="abc.pem")
registration_id = request.POST['registration_id']
message_title = request.POST['message_title']
message_body = request.POST['message_body']
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)
print result
return HttpResponse("Hello Testing, world. You're at the tesing index.")
else:
apns = APNs(use_sandbox=True, cert_file='abc.pem', enhanced=True)
token_hex = request.POST['registration_id']
messageTitle = request.POST['message_title']
dict = {'title': request.POST['message_title'], 'body': request.POST['message_body']}
payload = Payload(alert=dict, sound="default", badge=1)
apns.gateway_server.send_notification(token_hex, payload)
frame = Frame()
identifier = 1
expiry = time.time()+3600
priority = 10
frame.add_item(request.POST['registration_id'], payload, identifier, expiry, priority)
return HttpResponse("Hello Testing, world. You're at the tesing index second")
解决方案
推荐阅读
- python - 从 pandas 数据框中提取第一个和最后一个匹配的索引列表
- python - 使用最小化、差分演化和流域跳跃进行模型优化
- android - 增强每个循环的性能,每个循环都有一个内部循环
- javascript - 如何在 Draft.js 中停止插入符号闪烁?
- c++ - C++ Type Traits if_v(自动类型推断+确保相同类型)
- bash - 如何显示 HEAD 和 origin/master(或最新的共同祖先)之间的所有提交
- docker - 问题 Docker 上没有这样的文件或目录
- android - Kotlin 协程与线程
- go - TCP Protobuf 消息不一致地到达 Go 服务器的接收端
- reactjs - 我可以在所有钩子的依赖数组中放入什么类型的变量