简体   繁体   English

如何在 Cordova 中显示照片库权限对话框?

[英]How to display photo library permissions dialog in Cordova?

Hi we are developing an IBM MobileFirst Platform-based Hybrid Application.您好,我们正在开发基于 IBM MobileFirst 平台的混合应用程序。 In our application we are accessing user gallery (to upload photos).在我们的应用程序中,我们正在访问用户图库(上传照片)。 for this in iPhone we need to ask the user permission explicitly, to ask user permission in iPhone we need to display dialog box.为此,在 iPhone 中我们需要明确询问用户权限,在 iPhone 中要询问用户权限,我们需要显示对话框。 Here my question is the dialog box which we are going to show to the user is custom dialog box or is there any native feature built-in in MobileFirst, or with the help of any cordova plugin?在这里,我的问题是我们将向用户显示的对话框是自定义对话框还是 MobileFirst 中内置了任何本机功能,或者在任何cordova插件的帮助下?

You can use requestCameraRollAuthorization() in cordova-diagnostic-plugin to request native iOS permission to access the user photos:您可以在cordova-diagnostic-plugin 中使用requestCameraRollAuthorization()来请求访问用户照片的原生 iOS 权限:

cordova.plugins.diagnostic.requestCameraRollAuthorization(function(granted){
    console.log("Authorization request for camera roll was " + (granted ? "granted" : "denied"));
}, function(error){
    console.error(error);
});

MobileFirst does not handle any permissions for you - it is not that kind of a framework. MobileFirst 不会为您处理任何权限 - 它不是那种框架。 This really relates to the Cordova layer in your app, which access the photo library.这确实与您的应用程序中的 Cordova 层有关,它访问照片库。

You need to display a dialog box asking the user whether or not does s/he allow for the access to access the photo library.您需要显示一个对话框,询问用户是否允许访问照片库。 You can use WL.SimpleDialog for this purpose, for example.例如,您可以为此目的使用 WL.SimpleDialog。

Read more here:在此处阅读更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Xcode 中显示照片库图像? - How to display photo library image in Xcode? 如何使用更少的内存在 collectionView 中显示照片库 - How to display photo library in collectionView using less memory 科尔多瓦相机从iOS上的库中返回错误的照片 - Cordova camera returning the wrong photo from library on iOS Cordova - 如何将图像保存到 iOS 照片库? - Cordova - how to save an image to iOS photo gallery? 如何在照片库中获取URL? - How to get URL in Photo Library? 在用户允许使用照片库权限之前弹出“已保存照片”警报? - “Saved photo” alert popping up before the user allows permissions to photo library? 如何在从图片库拍摄的uiimageview中显示拾取的图像到另一个视图控制器中的另一个uiimageview中? - How to display picked image in a uiimageview taken from the photo library to another uiimageview in a different view controller? 如何全屏显示照片库中的任何图像? - How can I display any image from photo library at full screen? 如何从iOS照片库中获取图像并将其显示在UIWebView中 - How do I get an image from the iOS photo library and display it in UIWebView 如何在CollectionView中显示照片库或相机中的选定图像? 图库视图 - How can I display selected images from the Photo Library or Camera in a CollectionView? Gallery view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM