是否可以从视图控制器请求 APNS 设备令牌?
我是 Objective-C 和 iOS 开发的新手,但我想知道是否有一种方法可以从视图控制器请求 Apple 推送通知设备令牌,并将令牌存储在字符串中,以便稍后在发送到我的查询字符串中使用网络应用程序。
我一直在寻找,但未能找到解决此问题的方法。任何帮助将不胜感激!
I'm new to Objective-C and iOS development, but I was wondering if there was a way to request an Apple Push Notification Device Token from the View Controller and store the token in a string to use later in a Query String sent to my web application.
I've been searching, but haven't been able to find a solution to this. Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够在代码中的任何位置调用
registerForRemoteNotificationTypes:
。但是您必须在应用程序委托中实现
application:didRegisterForRemoteNotificationsWithDeviceToken:
。您最多可以注册 3 种不同类型的通知。只需根据需要删除并添加即可。
You should be able to call
registerForRemoteNotificationTypes:
anywhere in your code.But you'll have to implement
application:didRegisterForRemoteNotificationsWithDeviceToken:
in your app delegate.You can register for up to 3 different types of notification. Just remove and add as required.