Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 检查位置警报是否已解除_Iphone_Ios - Fatal编程技术网

Iphone 检查位置警报是否已解除

Iphone 检查位置警报是否已解除,iphone,ios,Iphone,Ios,如何检查用户是否已响应位置警报 “应用程序要使用您的当前位置” 或 “应用程序要向您发送推送通知” 我不在乎用户选择哪个选项,我只需要知道警报是否被解除,编辑:啊哈,我注意到您现在错误地将问题标记为uialertview 对于位置警报,您可以执行以下操作: - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { if (error.code == kCLEr

如何检查用户是否已响应位置警报

“应用程序要使用您的当前位置” 或 “应用程序要向您发送推送通知”


我不在乎用户选择哪个选项,我只需要知道警报是否被解除,

编辑:啊哈,我注意到您现在错误地将问题标记为
uialertview

对于位置警报,您可以执行以下操作:

- (void)locationManager:(CLLocationManager *)manager
   didFailWithError:(NSError *)error {

    if (error.code ==  kCLErrorDenied) {
        NSLog(@"Location manager denied access - kCLErrorDenied");

        UIAlertView *alert = 
              [[UIAlertView alloc] initWithTitle:@"Location issue" 
                                         message:@"Your location cannot be determined." 
                                        delegate:self 
                               cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    } 
} 
对于推送通知,您可以执行以下操作(尽管用户可能已响应或未响应):


当用户解除此警报时,您不会直接收到消息,但可以实现CLLocationDelegate的
-(void)locationManager:(CLLocationManager*)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
方法。在检查CLLocationManager的static
authorizationStatus
属性之前,您通常可以确定用户是否允许在您的应用程序中使用位置服务。

苹果禁止使用,因此您无法使用

您的回答假设问题涉及应用程序控制下的AlertView。问题是指系统发送的警报。@Bogatyr Yah OP使用了
uialertview
标记,这让我很困惑。现在编辑答案。感谢您对重复和琐碎问题的关注,但这不是我的问题!好的,我看你已经更新了答案。不要那么快就跳到问题海报上:)。不,这不是tru,就像Drew C提到的那样,你可以使用CLLocationDelegate来知道用户是否有回应,,
UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (status == UIRemoteNotificationTypeNone) {

     NSLog(@"User is not subscribed to receive push notifications");
}