我的项目中有以下代码,可以通过“ MPMediaPickerControllerDelegate”选择音频文件。当运行下面的代码时,第一次提示用户授予权限。如果用户拒绝加载,则选择器将自动失败。
如果用户最初拒绝后返回,是否可以提示用户授予权限?
我想知道这是否是一个错误。有什么方法可以检测到MPMediaPickerControllerDelegate的许可,以便我们决定是否显示音频。
下面是我的代码:
**2019-06-13T12:01:41.0216723Z error: deployment "yourapplication" exceeded
its progress deadline
2019-06-13T12:01:41.0382482Z ##[error]error: deployment "yourapplication"
exceeded its progress deadline
2019-06-13T12:01:41.0396315Z ##[error]/usr/local/bin/kubectl failed with
return code: 1
2019-06-13T12:01:41.0399786Z ##[section]Finishing: kubectl rollout
**
答案 0 :(得分:0)
您必须先检查授权许可,然后如果授权状态许可为authorized
,然后运行代码。如果不是notDetermined
,请寻求许可。如果是denied
,则显示“警告”,要求用户进入“设置”并启用此权限。
MPMediaLibrary.requestAuthorization({(newPermissionStatus: MPMediaLibraryAuthorizationStatus) in
// This code will be called after the user allows or denies your app permission.
switch (permissionStatus) {
case MPMediaLibraryAuthorizationStatus.authorized:
print("permission status is authorized")
case MPMediaLibraryAuthorizationStatus.notDetermined:
print("permission status is not determined")
MPMediaLibrary.requestAuthorization(MPMediaLibraryAuthorizationStatus -> permissionStatus)
case MPMediaLibraryAuthorizationStatus.denied:
print("permission status is denied")
case MPMediaLibraryAuthorizationStatus.restricted:
print("permission status is restricted")
}
})