Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

missing cordova.js #326

Open
smkamranqadri opened this issue Dec 3, 2018 · 16 comments
Open

missing cordova.js #326

smkamranqadri opened this issue Dec 3, 2018 · 16 comments

Comments

@smkamranqadri
Copy link

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.

@mbellezi
Copy link

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

@mbellezi
Copy link

my mjs_api_access:

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

@smkamranqadri
Copy link
Author

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

@boyofgreen
Copy link
Contributor

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.

@mbellezi
Copy link

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

@boyofgreen
Copy link
Contributor

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"
}
}

@mbellezi
Copy link

Yes, it is set. using plugin_mode.

@f2bo
Copy link
Contributor

f2bo commented Jan 23, 2019

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.

@mbellezi
Copy link

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

@756gzdz5
Copy link

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

@boyofgreen
Copy link
Contributor

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

@756gzdz5
Copy link

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

@756gzdz5
Copy link

756gzdz5 commented Mar 12, 2019

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.

@SamLoy
Copy link

SamLoy commented May 29, 2019

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 `<script src="cordova.js"/> 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

@rohanrichards
Copy link

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?

@gabrielenosso
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants