1 Reply Latest reply on Feb 14, 2017 4:04 AM by christianw2933200

    ios plugins not loading correctly - but after resuming to app




      I have a very strange issue with my iOS App. (App-ID = 281263)


      Everytime I try to use a plugin that shows something outside the webview (like the camera) it does not appear until I do something that forces the app to resume.


      In detail:

      1. I tap the "take picture" Button.

      2. camera.getPicture is called

      3. nothing happens, camera not showing up, neither success nor error callback triggered

      4. I press the home-button so the app is in background, an switch back into the app.

      5. camera shows up instantly, I can take a picture an upload it using the file-transfer plugin.


      instead of the 4th step I can also do other things that force the app to resume. for example pull down the iOS Status-Bar and push it up again.


      It is nothing specific about the camera plugin it also happens with phonegap-plugin-barcodescanner, cordova-plugin-dialogs and other plugins.


      I tried various things to find the source of the problem:

      - removed all plugins except camera

      - built with different phonegap-version (cli-6.0.0, cli-6.3.0, cli-6.5.0)

      - built with different deployment-target (8.0, 9.0, 10.0)

      - test on emulator or real device

      - checked out an older version of my app (that worked in Nov. 2016)


      But the error persists.


      The error does not happen with Android.



      What can I do to find the error?

        • 1. Re: ios plugins not loading correctly - but after resuming to app
          christianw2933200 Level 1

          I found the solution.


          I had a Content-Security-Policy meta-tag defined like this:

          <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *">


          It turns out default-src * is not enough.


          With the following policy it works:

          <meta http-equiv="Content-Security-Policy" content="default-src * 'self' data: gap:  https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *">

          The key part here ist the "gap:".

          I still find it strange that this policy is influenced by resuming to the app.