How to display photo library permissions dialog in Cordova?

后端 未结 2 693
孤街浪徒
孤街浪徒 2021-01-15 18:09

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

相关标签:
2条回答
  • 2021-01-15 18:13

    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);
    });
    
    0 讨论(0)
  • 2021-01-15 18:21

    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)
    0 讨论(0)
提交回复
热议问题