在生产模式下推送通知不来,但在发展中它是未来 [英] Push notification in Production mode is not coming But in development it is coming

查看:126
本文介绍了在生产模式下推送通知不来,但在发展中它是未来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的PNS工作在发展模式好。我这样做使用raywendelich博客。同样的方式我已经建立在生产模式证书和从服务器上运行同一个脚本,但没有收到任何通知。

哪些附加当我们在生产模式,从我们的server.Its非常迫切需要测试所需的步骤。 plase帮助什么生产模式做的。

我们的PHP code

 < PHP//把你的设备令牌这里(无空格):
$ deviceToken ='d5d89cab86e6f1a3cfa66dd853f3f4d7dd932c4a6da793cb9c86d31e9cfcb31f';//把你的私钥的密码在这里:
$密码=*******;//这里把你的警告信息:
$消息='****'; $ CTX = stream_context_create();
 stream_context_set_option($ CTXSSL,的local_cert',​​'ckm.pem');
 stream_context_set_option($ CTX,'SSL','密​​码',$密码); //打开到APNS服务器的连接
 $计划生育=在stream_socket_client(
SSL://gateway.push.apple.com:2195',$犯错,
$ errstr,60,STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT,$ CTX); 如果(!$ FP)
退出(无法连接:$犯错$ errstrPHP_EOL);回声连接到APNS。 PHP_EOL;//创建有效载荷体
$身体['APS'] =阵列(
'警报'=> $消息,
声音= GT; '默认'
);  // EN code中的有效载荷为JSON
 $有效载荷= json_en code($体); //生成二进制通知
 $味精= CHR(0)。包('N',32)。包(H *',$ deviceToken)。包('N',strlen的($有效载荷))。 $有效载荷; //它发送到服务器
 $结果=的fwrite($计划生育,$味精,strlen的($味精)); 如果(!$结果)
回声消息发送失败。 PHP_EOL;
 其他
回声的消息成功传递。 PHP_EOL;  //关闭与服务器的连接
  FCLOSE($ FP);


解决方案

您需要创建生产APNS证书(非常类似于您创建的开发者证书的方式),并用它来连接到苹果来代替。开发和生产pushtokens是不同的,所以为了得到您的生产推的道理,你就必须建立自己的应用程序的即席版本。当您在设备上安装临时版本,如果你想收到推送令牌应该问你。接受你的code应该把你的生产令牌推到你的服务器(我假设你保存所有pushtokens一台服务器上的某个地方)。这是你需要用它来测试你的生产推code中的令牌。

My PNS is working good in development mode. I have done this using raywendelich blog. same way i have created certificates in production mode and run same script from server but not receiving any notification.

Which additional step needed when we are testing in production mode from our server.Its very urgent need. plase help what to do for production mode.

our PHP code

<?php

// Put your device token here (without spaces):
$deviceToken = 'd5d89cab86e6f1a3cfa66dd853f3f4d7dd932c4a6da793cb9c86d31e9cfcb31f';

// Put your private key's passphrase here:
$passphrase = '*******';

// Put your alert message here:
$message = '****';

 $ctx = stream_context_create();
 stream_context_set_option($ctx, 'ssl', 'local_cert', 'ckm.pem');
 stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

 // Open a connection to the APNS server
 $fp = stream_socket_client(
'ssl://gateway.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($payload))   . $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);

解决方案

You need to create the production APNS certificate (very similar to the way you created the developer certificate) and use that to connect to Apple instead. The development and production pushtokens are different so in order to get your production push token, you'll have to build an AdHoc version of your app. When you install the ad-hoc version on your device, it should ask you if you want to recieve push tokens. Accept and your code should send your production push token to your server (I'm assuming you save all pushtokens on a server somewhere). This is the token you need to use to test your production push code.

这篇关于在生产模式下推送通知不来,但在发展中它是未来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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