iOS:注册令牌无效。检查令牌格式 [英] iOS: Invalid registration token. Check the token format

查看:527
本文介绍了iOS:注册令牌无效。检查令牌格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Firebase以及iOS的新用户。我尝试使用FCM发送推送通知。



我在FCM上注册了一个iOS应用程序。已添加 .p12 证书。根据FCM开发的代码。



通过 Firebase控制台,我收到错误注册令牌无效。检查令牌格式。。我不会犯什么错误。 $ b

解决方案

解决这个问题

为iOS提供的 FCM 教程。但在测试或实施时,我使用了 APN服务器
使用APN服务器时,只需要 .pem 文件



这个是我的 .py 文件代码

 从apns导入随机
导入APN,帧,有效载荷

sound =default
badge = None
alert =Message
identifier = random.getrandbits(32)

apns_enhanced = APNs(use_sandbox = true,cert_file ='vendor.pem',enhanced = True)
payload = Payload(alert = alert,sound = sound,badge = badge)
apns_enhanced.gateway_server.send_notification(token_hex_office,payload,identifier =标识符)
apns_enhanced.gateway_server.force_close()

我将提供更多描述性的 answer later



谢谢

I am new for Firebase as well as for iOS. I am trying to send push notification using FCM.

I registered an iOS app on FCM. Both .p12 certificates added. Code developed according to FCM.

While sending notification through the Firebase Console, I'm getting the error Invalid registration token. Check the token format.. I don't what mistake I did.

解决方案

To solve the this issue

I followed complete tutorial of FCM provided for iOS. But while testing or implementing I used APN Server. While using APN Server you need only .pem file

For reference this is my .py file code

import random
from apns import APNs, Frame, Payload

sound = "default"
badge = None
alert = "Message"
identifier = random.getrandbits(32)

apns_enhanced = APNs(use_sandbox=True, cert_file='vendor.pem', enhanced=True)
payload = Payload(alert=alert, sound=sound, badge = badge)
apns_enhanced.gateway_server.send_notification(token_hex_office, payload, identifier=identifier)
apns_enhanced.gateway_server.force_close()

I'll provide more descriptive answer later

Thanks

这篇关于iOS:注册令牌无效。检查令牌格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆