我在IOS google推送通知中收到此错误
无法完成操作。 (com.google.gcm错误501。)
我在开发环境和生产环境中获得了注册ID。
发展环境的信息:
{"multicast_id":8145067860904395870,"success":1,"failure":0,"canonical_ids":0,"results":
[{"message_id":"0:1452842547360715%bc92eed1bc92eed1"}]}
我成功收到了消息。
但在生产环境中,我收到此消息。
{"multicast_id":8861850059359760561,"success":0,"failure":1,"canonical_ids":0,"results":
[{"error":"NotRegistered"}]}
并且未收到任何通知。
我已经尝试过撤销证书并创建新证书和新配置文件到清理构建文件夹,但通知仍然无法在生产中使用。
答案 0 :(得分:0)
我的解决方案是,我必须转到AppDelegate.swift文件并在开发中搜索kGGLInstanceIDAPNSServerTypeSandboxOption,它应该是true,对于生产它应该是false。刚刚将其更改为false以进行制作,通知对我有效。
答案 1 :(得分:0)
你可以在生产环境中这样做。:
GGLInstanceID.sharedInstance().startWithConfig(instanceIDConfig)
registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:false]
GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID,
scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)