如何从 apns 获取设备令牌到设备?
我想在我的应用程序中使用推送通知。我想知道我是否需要在我的应用程序中包含证书来获取设备令牌,或者我只需要在钥匙链中安装证书并仅实现 PushNotificationGuide 中描述的方法?实际上我对是否在我的应用程序中集成证书有点困惑。我只想知道客户端实现的逐步方法。很抱歉发布这个问题,因为我知道有很多关于堆栈溢出的帖子。感谢大家的支持。
I want to use push notification in my app.i want to know that do i need to include certificate in my app to get device token or i just need to install certificate in key chain and implement only the methods which are described in PushNotificationGuide? actually I'm a bit confused about whether i integrate certificate in my app or not.I just want to know a step by step method for client side implementation. sorry for posting this question cause i know there are a lot posts on stack overflow.thanks all for your support.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该不将证书集成到您的应用中。如果您这样做,任何人都可能欺骗您的推送服务器并向所有用户发送推送。推送的工作方式大致如下:
在将来的某个时刻,您可以使用该令牌来发起推送连接,大致方式如下图所示(来自 Apple 文档:
APNS 图 http://developer.apple。 com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Art/remote_notif_simple.jpg
这个 是一篇不错的博客文章,解释了如何构建应用程序和服务器,Apple 有示例代码,展示了如何获取设备令牌 此处。
You should NOT integrate the certificate into your app. If you do that it will be possible for anyone to spoof your push server and send pushes to all of your users. The way push works is roughly:
At some point in the future you use that token to initiate a push connection in roughly the way shown in this image from Apple's documentation:
APNS Diagram http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Art/remote_notif_simple.jpg
This is a decent blog post explaining how to build an app and server, and Apple has sample code showing how to get the device token here.