推进分配的通知 [英] Push notifications on distribution

查看:139
本文介绍了推进分配的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的所有证书,以推动下发展的通知我的应用程序的iPhone。
如果我与开发者证书创建的文件。质子交换膜测试它的工作,但如果我使用由生产证书创建的文件。质子交换膜它不能正常工作。

I create all certificates to develope push notify for my app iPhone. If I test it with file .pem created by developer certificates it work, but if I use file .pem created by production certificates it not work.

这是我的code:

public function push($deviceToken,$badge,$message,$deviceType) {

              $sound = "default";

              // Construct the notification payload
              $body = array();
              $body['aps'] = array("alert" => $message);

              if ($badge)
                    $body['aps']['badge'] = $badge;
              if ($sound)
                    $body['aps']['sound'] = $sound;

              $ctx = stream_context_create();
              stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-prod.pem');
              $fp = stream_socket_client("ssl://gateway.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);

              if (!$fp) {
                    print "Failed to connect $err $errstrn";
                    return;
              } else {
                    print "Connection OK\n";
              }

              $payload = json_encode($body);
              $msg = chr(0) . pack('n',32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack('n',strlen($payload)) . $payload;
              fwrite($fp, $msg);
              fclose($fp);

    }

任何建议?

推荐答案

一定要后推过程中创造的证书,创建一个新的即席和AppStore的或经销证书。自组织和AppStore的证书更改推使应用程序。

Be sure to create a NEW adhoc and or appstore distribution certificate AFTER creating the certificates for the push process. The adhoc and appstore certificates change for push-enables apps.

这篇关于推进分配的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆