我设置了一个带有 manager-apns 的服务器,因此可以进行注册,并且部分发送正在工作。我的应用程序能够注册到 APNS 服务,但我仍然无法收到任何通知。当我发送时,我可以看到它排队,然后发送,但消息永远不会到达我的应用程序。
我尝试使用 Apple 的 TN2265 进行故障排除,并使用 PersistentConnectionLogging 调试工具,我的应用程序看不到任何“已接收启用主题的消息”。我不知道在哪里寻找!
我看到的唯一奇怪的事情是“为启用的哈希发送过滤器消息”发生了 2 次,仅适用于我的应用程序:
2013-07-26 15:08:43 +0200 apsd[76]: <APSCourier: 0x1cd7acd0>: Sending filter message for enabled hashes {
<f64ea2b9 ab3ff7b0 fd1434d0 29915479 7ede3451> = "ch.arno.airmet";
} and ignored hashes {
}
一次与出现在我手机通知服务下的所有其他应用程序一起使用:
2013-07-26 14:52:21 +0200 apsd[76]: <APSCourier: 0x1cd5b970>: Sending filter message for enabled hashes {
<00d2590f de623fa5 4daaff34 141ee00e 0901f374> = "ch.admin.meteoswiss";
<5323275a 2f8a5b9f 02c764cc 626ee7e6 2f63f1e0> = "com.viber";
<852ba2ea 01feadaf c01d9008 e4126d14 ec5259b3> = "com.apple.itunesconnect.mobile";
<ed98cabb 18f6456b fddf7fec 19097b75 a21217ac> = "com.apple.itunesstored";
<b1e43d18 e02389f7 6e7468cb f2724d06 7bdfe1b2> = "org.arrl.arrl";
<bc1f77cb da300ce4 81e852d5 bf22e623 ec5e091a> = "uk.co.leeus.planefinder";
<473b1564 871c0c26 28458f58 f23fc00e c118dd9f> = "com.solarimpulse.iosApp";
<e7f612ad e3f961cb 0ac0a81b 6bdf57bc 694f7428> = "ch.mobilemed.echo112";
<0ce2a170 a161da7f 5f69bf26 ee0809fb 0668e1ce> = "com.facebook.Facebook";
<12b4fdbc cba5eaba 2c17bdbe 22dcc0ee 57835566> = "net.whatsapp.WhatsApp";
<e85619ab d42029c7 481a7ac1 9092bb46 90cbee76> = "com.apple.ess";
<7534fab8 84f14472 afe97dae be5befc4 705da00b> = "com.medlmobile.nra";
<7981dd6f f81e3c91 d91509d5 ebcd5e79 bd4af29f> = "ch.local.search.launcher";
} and ignored hashes {
<ca7bf4cd b904cd8c 41b61ff6 9518dd16 6b76780b> = "com.shazam.Shazam";
<07f67690 61ef66b3 5263ccfc 4999aebd 24660517> = "com.giggleup.tc1free";
<ecf79b66 385fd443 09d13301 97a333b0 3399c7da> = "ch.teleboy.Teleboy";
<10132f99 870d0f9d 70361cf6 6d6610a5 ed624d9f> = "ch.edipresse.lematin";
<cee727be 3abd4b5a b08f2dea 1386944f de9c0a74> = "com.ebay.iphone";
<22d7a21b 76ee7ffe 6ca350b5 99050ab6 262c78b0> = "ch.rts.couleur3.ios";
<88b112b4 1932b794 6c108a0a 216553b9 0fffaece> = "com.chairentertainment.IB2";
<9f9c9ad5 b5655e77 2381b57c 623b27f3 45edfc7b> = "com.sega.sjump";
<2a66964c 844725bd d0eef3d0 ea63cd04 9923faf0> = "ch.edipresse.vqh";
<e24289ab caeb387d 21b5083c 68b647ce 4df387e3> = "com.outfit7.talkingdog";
<40165135 742995c5 acafd4cf e8492faf 5c3f9780> = "5Q4J53EFRC.com.sbb.ch";
<c0cbf607 951fdb5b c0905310 b8524d4c 6f3a187d> = "com.touchpress.atlas.ipad.english";
<a4421ecb ef0ca44c f5f683ee 4a817b6e 225a16e5> = "com.glu.pinkslip";
<cf2c3d22 a50d9f3a f1d37d98 6afc8971 0b5c2948> = "com.vitotechnology.StarWalk";
<3a7c8c40 a9a7de34 4c3a35c8 9feaa514 72310917> = "com.zentertain.ringmakerfree";
<a2e43ec2 cad8bc3b 99a2ba8f a9626c71 62b7068a> = "com.outfit7.talkingtom";
<8c3f23ff 0dde87a3 2ad02d41 3fbd69b4 86f86983> = "com.outfit7.talkinggina";
<9def7a9f f25f2141 ef4f9008 f3b16620 f888f66e> = "com.outfit7.talkingtom2";
<fffc05c7 628714bd 08802dd7 8728875c 63c09447> = "com.linkedin.LinkedIn";
}
我也尝试使用此代码发送推送通知:
<?php
// Put your device token here (without spaces):
$deviceToken = 'ad53879a3ad06c5d23acd502e19f6488fb3a722ac163c5f47b3ba4d3df4bef54
';
// Put your private key's passphrase here:
$passphrase = '';
// Put your alert message here:
$message = 'My first push notification!';
////////////////////////////////////////////////////////////////////////////////
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'include/certs/airmet/sandb
ox.pem');
stream_context_set_option($ctx, 'ssl', 'verify_peer', false );
stream_context_set_option($ctx, 'ssl', 'ciphers', 'ALL:SSLv3:TLSv1');
stream_context_set_option($ctx, 'ssl', 'cafile', 'ca.pem');
//stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
'tcp://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($pay
load)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;
// Close the connection to the server
fclose($fp);
?>