Not Getting Push Notification for Production Certificate

半城伤御伤魂 提交于 2019-12-12 06:28:11

问题


I have read many answers on this topic but issue not resolved by suggested solutions. My issue is that I am not getting Push Notifications for Production Certificate. Same Push Notifications are successfully getting in Development certificate. I specially want to say that my device tokens for production and development environment is entirely different. So there is no issue for same device token. Also, i am using different profiles for both. Means to say, there is not configuration issue on app level.

We are using PHP as a server that is sending push notifications.

Here are my two questions:

  1. Is there any thing missing at server side? For which PHP server is sending Push Notifications for development environment successfully and for Production environment, its generating problem?
  2. Am i missing any thing in the app?

I will be very thankful to all of you. I am stuck on this issue. Many Thanks in advance


回答1:


check php function for iphone push notification...

function iphone_notification($deviceToken,$message,$not_type,$sound,$vibration_type){
            $passphrase = '******';
            $ctx = stream_context_create();
            stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
            stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
            $fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
            $body['aps'] = array('alert' => $message, 'sound' => $sound);
            $body['notification_type'] = $not_type;
            $body['vibration_type'] = $vibration_type;
            //1 = news;
            //99 = other;
            //echo $err."<br>".$errstr;
            $payload = json_encode($body);
            $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
            $result = fwrite($fp, $msg, strlen($msg));
            fclose($fp);
    }



回答2:


I faced this same problem. If your .pem file is correct then using following setting you will get push notification. (check terminal commands to make .pem)

//for development profile
$apns_url = 'gateway.sandbox.push.apple.com';

//for production you should use this
$apns_url = 'gateway.push.apple.com';s. 

for more detail check this link1 >> link2 >>



来源:https://stackoverflow.com/questions/23471477/not-getting-push-notification-for-production-certificate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!