![](/img/trans.png)
[英]send notification like push notification without APNS server in ios,
[英]APNs Message send to Server, No notification comes on device iOS
我为服务器配置了apns_certificate.pem和apns_privatekey.pem。 我正在使用node.js服务器发送推送通知。 我已成功向apns服务器发布通知,但设备未收到任何推送通知。
我还经历了推送通知疑难解答 。 我按照故障排除文档中的描述,通过服务器端的命令检查了所有pem文件。
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile server-ca-cert.pem
它很成功。
我检查了我的服务器能够通过以下命令连接到apns服务器。
$ telnet 1-courier.push.apple.com 5223
$ telnet gateway.sandbox.push.apple.com 2195
$ telnet gateway.push.apple.com 2195
我在iOS项目上正确配置它,我也得到了设备令牌。
但我仍然没有在我的设备上获得推送通知。
请检查设备令牌是否有效。 对于哪个设备令牌,服务器发送推送通知。 此外,推送通知应检查应用程序后台模式。
如果以上都正确,您将收到推送通知。
同时在app delegate中检查这两种方法,并将设备令牌从iOS应用程序发送到服务器:
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
str = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"This is device token%@", str);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"Error %@",err);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.