【发布时间】:2015-09-29 11:04:08
【问题描述】:
我正在尝试通过 VB.Net 发送 iPhone 推送通知,尽管我可以通过 PHP 发送它们。 我已经尝试了这两种方法(适用于 Android),但它们在 iPhone (ios) 上都失败了。
这是我一直在使用的代码和遇到的问题:
VB.Net
Dim appleCert As Byte()
appleCert = File.ReadAllBytes("C:\AppleAppKey\aps_development.p12")
push.RegisterAppleService(new ApplePushChannelSettings(appleCert, "123xxx321"))
push.QueueNotification(new AppleNotification() _ .ForDeviceToken("06611dd37b6e0fff87da9edd8j97ddf337246274e0dd3a77fc7d7a14") _
.WithAlert("Hello World!") _
.WithBadge(7) _
.WithCustomItem("content-available", 1))
错误:未返回错误,但未向手机发送通知。
PHP
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer');
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', self::$passphrase);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60,STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
错误:stream_socket_client() SSL:找不到指定的过程。
我创建了一个 Apple Developer 帐户并创建了 .pem .p12 .cer 文件。 我还通过 telnet 测试了 Apple 连接
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert ios_development.pem -key aps_development.pem -CAfile entrust_2048_ca.cer
这行得通。
有人可以指点我正确的方向吗?
【问题讨论】:
标签: php iphone vb.net mobile push-notification