0

I've been using this plugin https://github.com/dpa99c/cordova-diagnostic-plugin for a long time and works fine. Nowadays I'm using framework7, which is awesome. I've got this code to ask for camera permission, which works fine

  onDeviceReady: function() {


            cordova.plugins.diagnostic.requestCameraAuthorization(
                function(status){

                    console.log("Authorization request for camera use was " + (status == cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));

                    if (myApp.device.ios) { 

                             cordova.plugins.diagnostic.isCameraRollAuthorized(function(authorized){
                              if (!authorized) {
                                   cordova.plugins.diagnostic.requestCameraRollAuthorization(function(granted){

                                   }, function(error){
                                      console.log("Authorization request for camera roll has error " + error.code + " - "+ err.msg);
                                   });

                              }
                            });
                      }

                }, function(error){
                    console.error("The following error occurred: "+error);
                }, false
            );   

but after allowing the camera to take pictures, my app stays freeze, I can write on input box, but when I click on any button/link nothing happens. I have no console errors and it happens only on iOS. If you restart the app, everything works fine. I also try adding this plugin:

<gap:plugin name="cordova-plugin-ios-camera-permissions" source="npm" > 
  <variable name="CAMERA_USAGE_DESCRIPTION" value="La aplicacion requiere el permiso para tomar fotografias." />
  <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="La aplicacion requiere el permiso para acceder a la lista de fotografias." />
</gap:plugin>
chispitaos
  • 767
  • 9
  • 14

1 Answers1

1

If you restart the app, everything works fine

This sounds like a possible symptom of the issue caused by insufficient privileges in the CSP on iOS 10. See this question for details and full answer, but in a nutshell, make sure your Content-Security-Policy meta tag contains gap://ready and file, e.g.:

<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src fonts.googleapis.com 'self' 'unsafe-inline'; img-src framework7.io 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'">
DaveAlden
  • 30,083
  • 11
  • 93
  • 155
  • This line, cause me these troubles: Refused to load the stylesheet 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline'". Refused to load the stylesheet 'https://fonts.googleapis.com/icon?family=Material+Icons' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline'". Refused to load the image 'https://framework7.io/i/logo-new.png' because it violates the following Content Security Policy directive: "img-src 'self' data:". – chispitaos May 30 '17 at 11:56
  • 1
    iOS 10 now strictly applies CSP rules, so until you get your whitelisting right, your app will not work properly. You need to whitelist the appropriate domains in your Content Security Policy to avoid these errors. I've edited the example CSP above to illustrate this for your particular errors. – DaveAlden May 30 '17 at 20:51