ios - 找出用户在 iOS 显示的 UIAlertView 上选择了哪个按钮的方法,请求允许应用程序接收推送通知的权限

标签 ios iphone apple-push-notifications uialertview

有没有办法与 iOS 显示的警报进行交互。例如:如果我的应用程序已为 APNS 注册,在第一次启动时,iOS 会显示一个 UIAlertView(我假设它是一个),给用户两个选择。有没有办法找出用户选择了哪个按钮? 在我的应用程序启动期间,我有两个警报显示,一个用于 APNS,另一个用于定位服务。有没有办法确定哪个警报是针对什么?

最佳答案

如果您无法直接访问这些警报,我建议您从另一个角度来看这个问题。

例如,对于 CoreLocation,您可以查看它的 [CLLocationManager authorizationStatus]

   kCLAuthorizationStatusNotDetermined = 0, // User wasn't proposed to use location services
   kCLAuthorizationStatusRestricted, // Parental control or something like that
   kCLAuthorizationStatusDenied,    // User didn't allow this application to use services
   kCLAuthorizationStatusAuthorized // User allowed to use his location.

至于 APNS,有 [[UIApplication sharedApplication] enabledRemoteNotificationTypes]

来源: https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UIRemoteNotificationType

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/doc/c_ref/CLAuthorizationStatus

关于ios - 找出用户在 iOS 显示的 UIAlertView 上选择了哪个按钮的方法,请求允许应用程序接收推送通知的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21673919/

相关文章:

ios - UIImageView 不继续

ios - 自动调整蒙版和全屏 View

ios - 制作单个 ios 应用程序的多个副本

iphone - 横向模式下的 UIScrollView 框架大小问题

ios - 通知在 APNS 服务器上存储多长时间?

ios - 设备上线后 iOS 中推送通知的异常行为

ios - "Use for development"在 Xcode 内部做什么?

ios - Objective-C简单数学问题

javascript - CATransition 在所需 View 之外显示动画

ruby-on-rails - 在 ruby​​ 中构建公钥时是什么导致 "Neither PUB key nor PRIV key::nested asn1 error"?