php APNS:无效令牌 (8)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16501519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:14:30  来源:igfitidea点击:

APNS: invalid token (8)

phpobjective-cpush-notificationapple-push-notificationsapns-php

提问by Jason Silberman

I am using the apns php server provided at https://code.google.com/p/apns-php/.

我正在使用https://code.google.com/p/apns-php/提供的 apns php 服务器。

I've have set up th push notification certificate but my code still throws an error on connect.

我已经设置了推送通知证书,但我的代码仍然在连接时引发错误。

What is wrong with this? Here is how I get the device token:

这有什么问题?这是我获取设备令牌的方法:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {

#if !TARGET_IPHONE_SIMULATOR

    // Prepare the Device Token for Registration (remove spaces and < >)
    NSString *deviceToken = [[[[devToken description]
                               stringByReplacingOccurrencesOfString:@"<"withString:@""]
                              stringByReplacingOccurrencesOfString:@">" withString:@""]
                             stringByReplacingOccurrencesOfString: @" " withString: @""];
    NSLog(@"%@", deviceToken);

#endif
}

This is the error when I run my server:

这是我运行服务器时的错误:

Sat, 11 May 2013 13:37:53 -0700 ApnsPHP[18198]: INFO: Trying 
ssl://gateway.push.apple.com:2195...
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Connected to ssl://gateway.push.apple.com:2195.
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Sending messages queue, run #1: 1 message(s) left in queue.
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: STATUS: Sending message ID 1 [custom identifier: abc123] (1/3): 101 bytes.
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: ERROR: Unable to send message ID 1: Invalid token (8).
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Disconnected.
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Trying ssl://gateway.push.apple.com:2195...
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Connected to ssl://gateway.push.apple.com:2195.
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Sending messages queue, run #2: 1 message(s) left in queue.
Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: WARNING: Message ID 1 [custom identifier: abc123] has an unrecoverable error (8), removing from queue without retrying...
Sat, 11 May 2013 13:37:55 -0700 ApnsPHP[18198]: INFO: Disconnected.

回答by Eran

The most likely explanation is that you are sending a push notification with a sandbox device token to the production APNS server.

最可能的解释是您正在向生产 APNS 服务器发送带有沙盒设备令牌的推送通知。

Either you are using an old device token that was sent to your server by your app while you were testing it in the sandbox environment, or your app is still signed with a development provisioning profile, and is still receiving sandbox device tokens from the APNS service.

您使用的是在沙盒环境中测试时由应用程序发送到服务器的旧设备令牌,或者您的应用程序仍使用开发配置文件进行签名,并且仍在从 APNS 服务接收沙盒设备令牌.

My answer assumes that you are using a device token that originated from the APN service, and not some dummy token you created yourself .

我的回答假设您使用的是源自 APN 服务的设备令牌,而不是您自己创建的一些虚拟令牌。

I suggest you check the provisioning profile to see what value appear for the aps entitlement. I also suggest you clear your db from any old device tokens.

我建议您检查配置文件以查看为 aps 权利显示的值。我还建议您从任何旧设备令牌中清除您的数据库。