doudui2229 2013-05-21 05:03
浏览 22
已采纳

移动到EC2实例后,APNS推送不工作,而不是“失败”

So, I moved my application to an EC2 instance, and Apple Push Notification Service stopped working. I'm using the same certificate, same script, same everything.

  • I've opened port 2195 in the security group for the EC2 instance.
  • from the EC2 intance, telnet gateway.push.apple.com 2195 works
  • my script receives no errors... everything gets to the end, even fwrite returns true... yet, I receive no push.

Things to note.

  • My EC2 instance is accessed via https where my old server was http, but since the script would be running locally, and has nothing to do with Apache, I don't see why this should matter. But, perhaps it does, so I'm letting you know :D

My script:

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$ssl = 'ssl://' . $apnsHost . ':' . $apnsPort;
$apns = stream_socket_client($ssl, $error, $errorString, 30, STREAM_CLIENT_CONNECT, $streamContext);
if($apns == false){
    echo "Error: $errorString";
    return false;
}
$payload['aps'] = array('alert' => $message, 'badge'=>$badge, 'sound' => 'default');
$payload = json_encode($payload);

$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $device_id)) . chr(0) . chr(strlen($payload)) . $payload;
if(fwrite($apns, $apnsMessage)){
    return true;
}
return false;

I've checked all of my variables, they are set.

Any help would be greatly appreciated. This is driving me bonkers :P

  • 写回答

1条回答 默认 最新

  • dongqixuan3112 2013-05-29 20:27
    关注

    Turns out I was giving a bad device id. The databases were different, and I stored something poorly. :(

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度