How can I check if the user has responded to Location alert
“App Would Like to Use Your Current Location” or “App would like to send you push notifications”
I don't care which choice the user select I only need to know if the alert is dismissed,,
You don't directly get a message when the user dismisses this alert, but you can implement CLLocationDelegate's - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
method. Between that and checking CLLocationManager's static authorizationStatus
property you can usually figure out whether the user has allowed location services in your app yet.
Apple禁止这样做,所以您不能这样做!
Edit: aha I noticed now that you had tagged the question erroneously with uialertview
.
For location alerts you can do:
- (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];
}
}
For push notifications you can do (although the user might have responded or not):
UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (status == UIRemoteNotificationTypeNone) {
NSLog(@"User is not subscribed to receive push notifications");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.