PWABuilder-CLI icon indicating copy to clipboard operation
PWABuilder-CLI copied to clipboard

missing cordova.js

Open smkamranqadri opened this issue 6 years ago • 16 comments

I am working on an old project built with manifold for iOS, now working to build android app.

I have added the platform and also added android in manifest under mjs_api_access but still the cordova file is not injecting.

Help in this regard is much appreciated.

smkamranqadri avatar Dec 03 '18 10:12 smkamranqadri

I'n having the same problem. The _cordovaNative is present but not cordova. How can it be injected?

mbellezi avatar Jan 21 '19 16:01 mbellezi

my mjs_api_access:

"mjs_api_access": [
    {
        "match": "*",
        "access": "cordova",
        "platform": "ios,windows,android"
    }
],
"mjs_cordova": {
    "plugin_mode": "client"
},

mbellezi avatar Jan 21 '19 16:01 mbellezi

Don't know, my problem still exist, maintainer please help us.

smkamranqadri avatar Jan 22 '19 03:01 smkamranqadri

hi folks, this is for android correct? have you reviewed the old docs:

https://github.com/pwa-builder/PWABuilder-CLI/wiki/Using-Cordova-Plugins-in-Hosted-Web-Apps you may need to set the cordova.js to be injected automatically, we had it set so that you could add it to your website, or have the tool auto inject it at page load.

boyofgreen avatar Jan 22 '19 18:01 boyofgreen

Yes, Android. Aren't the mjs_api_access and mjs_cordova directives enough to get cordova.js automatically injected at page load?

mbellezi avatar Jan 23 '19 16:01 mbellezi

so make sure you are have clien mode set: https://github.com/pwa-builder/PWABuilder-CLI/wiki/Using-Cordova-Plugins-in-Hosted-Web-Apps { ... "mjs_cordova": { "plugin_mode": "client" } }

boyofgreen avatar Jan 23 '19 18:01 boyofgreen

Yes, it is set. using plugin_mode.

mbellezi avatar Jan 23 '19 18:01 mbellezi

Have you tried with a different value for the match attribute in the mjs_api_access rule instead of '*'? I'm not sure that using a wildcard for the entire URL is supported. Try a more complete URL like https://github.com/* to see if that works.

f2bo avatar Jan 23 '19 20:01 f2bo

Yes, first I've tried the URL like https://github.com/* . I've changed to * after that.

mbellezi avatar Jan 23 '19 22:01 mbellezi

Did you update cordova ios? It seems like newer version don't work.

756gzdz5 avatar Feb 25 '19 14:02 756gzdz5

we did update but I don't think it has made it to public builds yet. @nbellocam right? Our update should get iOS working again. We are pushing it through the system this week

boyofgreen avatar Feb 25 '19 15:02 boyofgreen

@boyofgreen are you still planning on doing the update this week?

756gzdz5 avatar Feb 28 '19 08:02 756gzdz5

I just realized that you updated the IOS version in the meantime. After downloading the project, I added the following lines to the manifest and built the cordova project.

"mjs_extended_scope": [
        "*"
    ],
    "mjs_api_access": [
        {
            "match": "https://domain.com/*",
            "platform": "android,ios",
            "access": "cordova"
        }
    ]

Then, I ran it on an Iphone using Xcode and couldn't find the cordova.js. Is still supposed to work?

Those settings worked before, as long as I didn't update the cordova-ios-version that came with it.

756gzdz5 avatar Mar 12 '19 16:03 756gzdz5

I have been struggling with the same issue.

After playing with various combinations and following the various Wikis, the only time i've seen cordova.js served from the App's local files itself when the default index.html file is used instead of my webapp's index.html.

To load the default Cordova screen I removed the reference in config.xml which was pointing to my site: <content src="https://mywebsite.com"/>

The default index.html file references the cordova.js file, which is resolved to file:///android_assets/www/cordova.js image

If I add <content src="https://mywebsite.com"/> back into config.xml so my site's index.html file is used, the same link ` is resolved to https://mywebsite.com/cordova.js. Which doesn't exist..

image

Is it possible that the "client" plugin_mode in the manifest is being ignored, or perhaps not correctly passed down to the generated android app?

I have this in my manifest.json.

"mjs_cordova":` {
    "plugin_mode": "client"
  },
  "mjs_api_access": [{
    "match": "*",
    "platform": "android, ios, windows",
    "access": "cordova"
  }]

Alternatively, could it be the scope is now wrong when running against a remote website? So android_assets/www is not the default location, it will now be https://mywebsite.com

As an experiment I tried setting my website to reference cordova.js as <script src="file:///android_assets/www/cordova.js"/> But this gave the following console error in the android debugger: Not allowed to load local resource: file:///android_assets/www/cordova.js

Serving cordova.js and cordova_plugins.js as recommended here works. Although that is without the "plugin_mode": "server" being set. Which leads me to believe the setting is just ignored all together.

I would much rather use the client plugin_mode so I don't need to serve the plugins on my website. Has anyone successfully achieved this?

Thanks

SamLoy avatar May 29 '19 17:05 SamLoy

Would love to see some progress here, I have followed the above information (updated my manifest etc) and simply do not get a cordova.js asset within my web app. Seems a bit odd to me that an app generated with PWABuilder doesn't have access to cordova.js by default. @SamLoy did you ever make any progress?

rohanrichards avatar Jul 23 '19 03:07 rohanrichards

Any news here? This completely destroys the whole point of using pwabuilder.

gabrielenosso avatar Oct 14 '19 11:10 gabrielenosso