Iphone 我的应用程序只请求推送通知权限,但不请求位置。我怎样才能解决这个问题?

Iphone 我的应用程序只请求推送通知权限,但不请求位置。我怎样才能解决这个问题?,iphone,swift,xcode,push-notification,cllocationmanager,Iphone,Swift,Xcode,Push Notification,Cllocationmanager,在我的应用程序中,我有以下两行代码: manager.requestAlwaysAuthorization() UNUserNotificationCenter.current().requestAuthorization(options: [.sound,.alert], completionHandler: {didAllow, error in}) 但在加载时,我的应用程序只请求通知权限。如果用户没有使用其位置的权限,我的应用程序将无法工作。我怎样才能解决这个问题 我可以假设您已经授予

在我的应用程序中,我有以下两行代码:

manager.requestAlwaysAuthorization()
UNUserNotificationCenter.current().requestAuthorization(options: [.sound,.alert], completionHandler: {didAllow, error in}) 

但在加载时,我的应用程序只请求通知权限。如果用户没有使用其位置的权限,我的应用程序将无法工作。我怎样才能解决这个问题

我可以假设您已经授予或拒绝了它。要验证它,请尝试运行此代码:

let status = CLLocationManager.authorizationStatus()
并检测
CLLocationManager
的状态,现在您将知道它是哪种状态


如果状态为
未确定
以某种方式请求权限。

确保
nsLocationAlwaysSusageDescription
键存在,并且在您的Info.plist中有一个字符串值,否则位置权限对话框将不会出现

可能重复的