iPhone 收不到推送通知
我遇到这个问题已经 1 周了。我正在尝试以 3 种不同的方式让推送通知服务在我的应用程序上运行。以下是我遵循的步骤(我假设已完成开发者帐户的注册、应用程序 ID 的创建和推送证书的生成):
检索设备令牌。
- PushMeBaby iPhone 应用程序:
将 aps_developer_identity.cer 插入 PushMeBaby 应用程序的资源下。
将带空格的设备令牌(也尝试不带空格)复制粘贴到 self.deviceToken 中
将 aps_developer_identity 复制粘贴到 self.certificate
运行应用程序时,系统要求我允许使用私钥,这是我的输出:
2012-02-01 15:10:44.464 PushMeBaby[21219:903] MakeServerConnection(): 0
2012-02-01 15:10:44.482 PushMeBaby[21219:903] SSLNewContext(): 0
2012-02-01 15:10:44.486 PushMeBaby[21219:903] SSLSetIOFuncs(): 0
2012-02-01 15:10:44.488 PushMeBaby[21219:903] SSLSetConnection(): 0
2012-02-01 15:10:44.490 PushMeBaby[21219:903] SSLSetPeerDomainName(): 0
2012-02-01 15:10:44.492 PushMeBaby[21219:903] SecKeychainOpen(): 0
2012-02-01 15:10:44.493 PushMeBaby[21219:903] SecCertificateCreateFromData(): 0
2012-02-01 15:10:44.504 PushMeBaby[21219:903] SecIdentityCreateWithCertificate(): 0
2012-02-01 15:10:44.505 PushMeBaby[21219:903] SSLSetCertificate(): 0
2012-02-01 15:11:12.420 PushMeBaby[21219:903] SSLHandshake(): 0
然后当我按“push”时:
2012-02-01 15:11:26.767 PushMeBaby[21219:903] SSLWrite(): 0 78
并再次“推”:
2012-02-01 15:11:38.668 PushMeBaby[21219:903] SSLWrite(): 0 78
变量“processed”的值没有改变!当然,我的 iPhone 上没有收到任何推送通知。
- Javapns:
从网站 http://code.google.com/p/javapns/ 下载所需的库维基/一般要求
生成导出推送证书和与其关联的私钥的 .p12 文件。
将 java 代码复制粘贴
import javapns.Push;
public class PushTest {
public static void main(String[] args) {
Push.alert("Hello World!", "keystore.p12", "keystore_password", false, "My token");
}
}
到 java 类中,将设备令牌替换为正确的设备令牌(不带空格),添加 .p12 文件和正确的密码。
调试项目使我可以看到此消息:
已传输:设备令牌我的设备令牌
但我的 iPhone 中没有通知! 更改设备令牌时,我收到“无效设备令牌”消息
- php 脚本:
按照此处的步骤操作
收到消息:
已连接到 APNS
消息发送成功
,但我的 iPhone 上也没有收到任何通知!
你们知道出了什么问题吗? 可能是配置文件有问题吗?但是我能检索设备令牌吗?我在之前的一些问题中看到一些与日期设置相关的内容,所以我将其添加到 php 脚本中,并且我的 iPhone 设置为自动设置日期参数。我想我也尝试过退出该应用程序,但没有任何反应。我做了一些不寻常的事情,即使用 2 个不同应用程序的应用程序 ID,我现在只是胡乱猜测,因为我不知道该去哪里寻找。任何帮助将不胜感激。谢谢
It's been now 1 week that I am facing this problem. I'm trying to get the push notification service to work on my app in 3 different ways. Here are the steps I followed (I suppose registration for a developer account, creation of the app id and generation of the push certificate are done):
Retrieve the device token.
- PushMeBaby iPhone app :
Insert the aps_developer_identity.cer into the PushMeBaby app under Resources.
Copy paste the device token with spaces (also tried without spaces) into self.deviceToken
Copy paste aps_developer_identity into self.certificate
When running the app, I get asked to allow the use of the private key, here is the output I have :
2012-02-01 15:10:44.464 PushMeBaby[21219:903] MakeServerConnection(): 0
2012-02-01 15:10:44.482 PushMeBaby[21219:903] SSLNewContext(): 0
2012-02-01 15:10:44.486 PushMeBaby[21219:903] SSLSetIOFuncs(): 0
2012-02-01 15:10:44.488 PushMeBaby[21219:903] SSLSetConnection(): 0
2012-02-01 15:10:44.490 PushMeBaby[21219:903] SSLSetPeerDomainName(): 0
2012-02-01 15:10:44.492 PushMeBaby[21219:903] SecKeychainOpen(): 0
2012-02-01 15:10:44.493 PushMeBaby[21219:903] SecCertificateCreateFromData(): 0
2012-02-01 15:10:44.504 PushMeBaby[21219:903] SecIdentityCreateWithCertificate(): 0
2012-02-01 15:10:44.505 PushMeBaby[21219:903] SSLSetCertificate(): 0
2012-02-01 15:11:12.420 PushMeBaby[21219:903] SSLHandshake(): 0
Then when I press "push" :
2012-02-01 15:11:26.767 PushMeBaby[21219:903] SSLWrite(): 0 78
and "push" again :
2012-02-01 15:11:38.668 PushMeBaby[21219:903] SSLWrite(): 0 78
The value of the variable "processed" doesn't change ! And of course I do not get any push notification on my iPhone.
- Javapns :
Download the needed libraries form the website http://code.google.com/p/javapns/wiki/GeneralRequirements
Generate a .p12 file exporting the push certificate and the private key associated to it.
Copy paste the java code
import javapns.Push;
public class PushTest {
public static void main(String[] args) {
Push.alert("Hello World!", "keystore.p12", "keystore_password", false, "My token");
}
}
into a java class, replacing the device token with the right device token without spaces, adding the .p12 file and the right password.
Debugging the project allows me to see this message :
Transmitted: device token My device token
But no notification into my iPhone !
When changing the device token I have a "invalid device token" message
- php script :
Followed the steps here
Got the messages :
Connected to APNS
Message successfully delivered
But didn't get any notification on my iPhone either !
Would you guys have any idea on what went wrong ?
Could it be a problem with the provisioning profile ? But then would I be able to retrieve the device token ? I saw in some previous questions something related to the date setting so I added this in the php script and my iPhone is set to automatically set the date parameters. I think I tried also quitting the app, but nothing did. I did something unusual, which is using the app id for 2 different apps, I'm now just wild guessing since I don't know where to look. Any help would be much appreciated. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上是 IT 团队的一个错误,生成了错误的 SSL 推送证书!
并且问题中提到的变量“processed”的值与有效负载中的字符数有关。
It was actually an error from the IT team which generated the wrong SSL push certificate !
And the value of the variable "processed" mentioned in the question is related to the number of characters in the payload.