更新时间:2023-02-17 19:02:50
解决这个问题
为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