Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么iPhone没有';无法接收推送通知?_Iphone_Ios_Push Notification_Apple Push Notifications_Apns Php - Fatal编程技术网

为什么iPhone没有';无法接收推送通知?

为什么iPhone没有';无法接收推送通知?,iphone,ios,push-notification,apple-push-notifications,apns-php,Iphone,Ios,Push Notification,Apple Push Notifications,Apns Php,我真的不知道问题出在哪里。 我正在使用库APNSHPP发送推送通知。我还尝试了其他脚本,但也不起作用 我使用本教程生成推送证书(http://code.google.com/p/apns-php/wiki/CertificateCreation)并把它们放到苹果开发者的网站上。 我从iphone获得了正确的令牌,并将其放入示例_push.php中 我有MacBookPro 13英寸,2010年年中有MacOS Lion vojta:~/dev/www/application$ php sampl

我真的不知道问题出在哪里。 我正在使用库APNSHPP发送推送通知。我还尝试了其他脚本,但也不起作用

我使用本教程生成推送证书(http://code.google.com/p/apns-php/wiki/CertificateCreation)并把它们放到苹果开发者的网站上。 我从iphone获得了正确的令牌,并将其放入示例_push.php中

我有MacBookPro 13英寸,2010年年中有MacOS Lion

vojta:~/dev/www/application$ php sample_push.php 
Fri, 13 Apr 2012 16:23:24 +0200 ApnsPHP[6478]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195...
Fri, 13 Apr 2012 16:23:32 +0200 ApnsPHP[6478]: INFO: Connected to ssl://gateway.sandbox.push.apple.com:2195.
Fri, 13 Apr 2012 16:23:32 +0200 ApnsPHP[6478]: INFO: Sending messages queue, run #1: 1 message(s) left in queue.
Fri, 13 Apr 2012 16:23:32 +0200 ApnsPHP[6478]: STATUS: Sending message ID 1 [custom identifier: Message-Badge-3] (1/3): 109 bytes.
Fri, 13 Apr 2012 16:23:33 +0200 ApnsPHP[6478]: INFO: Disconnected.
如果我执行“php sample\u push.php”,我不会收到任何错误,但我的iPhone上也没有收到任何推送通知。

源示例_push.php:

// Using Autoload all classes are loaded on-demand
require_once 'ApnsPHP/Autoload.php';

// Instanciate a new ApnsPHP_Push object
$push = new ApnsPHP_Push(
    ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
    'server_certificates_bundle_sandbox.pem'
);

// Set the Root Certificate Autority to verify the Apple remote peer
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');

// Connect to the Apple Push Notification Service
$push->connect();

// Instantiate a new Message with a single recipient

$message = new ApnsPHP_Message('xxxx'); // i put my token here

// Set a custom identifier. To get back this identifier use the getCustomIdentifier() method
// over a ApnsPHP_Message object retrieved with the getErrors() message.
$message->setCustomIdentifier("Message-Badge-3");

// Set badge icon to "3"
//$message->setBadge(3);

// Set a simple welcome text
$message->setText('Hello APNs-enabled device!');

// Play the default sound
$message->setSound();

// Set the expiry value to 30 seconds
$message->setExpiry(30);

// Add the message to the message queue
$push->add($message);

// Send all messages in the message queue
$push->send();

// Disconnect from the Apple Push Notification Service
$push->disconnect();

// Examine the error message container
$aErrorQueue = $push->getErrors();
if (!empty($aErrorQueue)) {
    var_dump($aErrorQueue);
}
我还尝试了更简单的脚本(也不起作用)


我真的不知道该怎么办。请帮帮我。

向苹果发送推送通知时,它会返回一个状态码。您收到的状态码是什么?你是不是回0了

Status codes
0   No errors encountered
1   Processing error
2   Missing device token
3   Missing topic
4   Missing payload
5   Invalid token size
6   Invalid topic size
7   Invalid payload size
8   Invalid token
255 None (unknown)
我解决了。
这是因为XCode使用iOS团队配置文件签署了应用程序。删除此配置文件后,推送通知开始工作。

谢谢您的回答,但是使用函数流_socket _client的php脚本没有给我任何答案。您在服务器端使用什么?我真的在寻找一些我也可以调试的东西…Fri,06 Sep 2013 13:50:26+0200 APNSHPP[4632]:信息:正在尝试ssl://gateway.push.apple.com:2195... 2013年9月6日星期五13:50:27+0200 APNSHPP[4632]:信息:已连接到ssl://gateway.push.apple.com:2195. 2013年9月6日星期五13:50:27+0200 APNSHPP[4632]:信息:发送消息队列,运行#1:1个消息留在队列中。2013年9月6日星期五13:50:27+0200 APNSHPP[4632]:状态:发送消息ID 1[自定义标识符:未设置](1/3):55字节。2013年9月6日星期五13:50:28+0200 APNSHPP[4632]:信息:已断开连接。我收到此消息,但我有相同的问题。我删除了所有配置文件,但仍然没有响应。有什么想法吗?@SyedOsama,我遇到了同样的问题。你找到解决这个问题的办法了吗?@Jacobian,是的,我解决了这个问题。1) 检查你的.pem文件是否有RSA私钥?@SyedOsama,我解决了这个问题…重复了生产证书创建过程并解决了问题…我之前在生成推送证书时弄错了一些东西…谢谢
Status codes
0   No errors encountered
1   Processing error
2   Missing device token
3   Missing topic
4   Missing payload
5   Invalid token size
6   Invalid topic size
7   Invalid payload size
8   Invalid token
255 None (unknown)