How to display photo library permissions dialog in Cordova?

我是研究僧i 提交于 2019-12-01 11:49:18

问题


Hi we are developing an IBM MobileFirst Platform-based Hybrid Application. 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. 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?


回答1:


MobileFirst does not handle any permissions for you - it is not that kind of a framework. This really relates to the Cordova layer in your app, which access the photo library.

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.

Read more here:

  • http://docs.phonegap.com/en/3.3.0/guide_appdev_privacy_index.md.html#Privacy%20Guide
  • Cordova Camera Plugin in IOS 9
  • perhaps to check if there is access given, create also a Cordova plug-in that will check for it using native code: Determine if the access to photo library is set or not - PHPhotoLibrary (iOS 8)



回答2:


You can use requestCameraRollAuthorization() in cordova-diagnostic-plugin to request native iOS permission to access the user photos:

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


来源:https://stackoverflow.com/questions/33930953/how-to-display-photo-library-permissions-dialog-in-cordova

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!