14

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

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

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

- (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
}

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

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.
4

1 回答 1

26

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

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

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

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

于 2013-05-11T23:04:24.350 回答