简体   繁体   中英

Not Getting Push Notification for Production Certificate

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

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);
    }

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 >>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM