简体   繁体   English

搞砸Apple Push Notification Service

[英]Messing up the Apple Push Notification Service

I have been developing an app that uses push notifications. 我一直在开发一个使用推送通知的应用程序。 I have been messing around ALOT trying to fix the stupid provisioning stuff, and I really don't know what's what anymore. 我一直在纠缠很多尝试修复愚蠢的置备的东西,我真的不知道什么了。

I managed to fix the whole development push notifications. 我设法修复了整个开发推送通知。 And now, we are close to release. 现在,我们即将发布。 However, the switch to Production notification didn't go as smooth as expected. 但是,切换到生产通知的过程并不像预期的那样顺利。 And I still don't really understand the whole provisioning-thing. 而且我仍然不太了解整个预配置。

I thought I just had to switch out the .pem file with a new one, generated from a new .cer and .p12 file, aswell as remove the "sandbox" from the url it's trying to connect to. 我以为我只需要用一个新的.cer和.p12文件生成的新文件替换.pem文件,并从它尝试连接的URL中删除“沙盒”即可。 This just resulted in "Failed to connect: 0" in my .php sending the push. 这只是导致我的.php发送推送时出现“无法连接:0”。

.php .php文件

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'dp.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);

if(!$fp)
    exit("Failed to connect: $err $errstr" . PHP_EOL);

After messing around with the .p12 and .cer and .cert and .pem and .mobileprovision .ipa, I really don't know what to do anymore.. Why do we have to convert to .pem and merge them? 在弄乱了.p12和.cer和.cert和.pem和.mobileprovision .ipa之后,我真的不知道该做什么了。为什么我们必须转换为.pem并将它们合并? Is this REALLY the way Apple intended for us to do this? 这真的是Apple打算让我们这样做的方式吗? Or have I been following a pretty redicolus tutorial? 还是我一直在关注一个漂亮的redicolus教程?

What .cer file do I need? 我需要什么.cer文件? Which profile should the app use? 该应用应使用哪个个人资料? AppID vs provision vs device vs Certificate. AppID,供应,设备,证书。 What the hell.. Should I have to do anything other than switching to a new .pem file and remove the "sandbox". 该死的..除了切换到新的.pem文件并删除“沙箱”外,我是否还需要做其他事情。 I have activated and downloaded the "Production Push SSL Certificate" from the portal, and generated my .pem file from that. 我已经从门户网站激活并下载了“生产推送SSL证书”,并由此生成了我的.pem文件。 I have tried reading up on this, but it is reeeally hard and a stupid setup! 我已经尝试过阅读此书,但是这确实很难,而且是一个愚蠢的设置! I'm sure I have done something wrong. 我确定我做错了什么。 But can't figure out what, where and why! 但是无法弄清楚什么,在哪里和为什么!

推送通知服务 -很棒的教程,您将找到php脚本+回答所有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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