为什么Google Cloud Messaging通知无法与iPhone生产环境一起使用?

nis*_*tel 2 iphone ios google-cloud-messaging

我正在开发一个从PHP服务器接收推送通知的iPhone应用程序.

要发送通知,我正在使用Google Cloud Messaging.GCM在iPhone开发环境中运行良好,但我无法接收iPhone生产环境的通知,并且我不断收到此错误消息:

{
    "multicast_id":7214972633373567187,
    "success":0,
    "failure":1,
    "canonical_ids":0,
    "results":[
        {
            "error":"NotRegistered"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我尝试了很多,也搜索了很多,但没有找到解决这个问题的任何解决方案.请帮帮我.

我创建了.p12生产环境证书并将其上传到Google Cloud Messaging配置文件.

nis*_*tel 10

最后我找到了解决方案.现在使用GCM(Google Cloud Messaging)我可以向iPhone设备发送通知.

appDelegate.m刚需改变一个条件applicationDidBecomeActive的方法.

这是用于生产环境的代码:

_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                         kGGLInstanceIDAPNSServerTypeSandboxOption:@NO};
Run Code Online (Sandbox Code Playgroud)

这是用于开发环境的代码:

_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                         kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};
Run Code Online (Sandbox Code Playgroud)