pwa-builder / manifoldcordova Goto Github PK
View Code? Open in Web Editor NEWJS Plugin for Cordova
License: Other
JS Plugin for Cordova
License: Other
I'm injecting a javascript file to do some mobile-specific things like set up notifications etc...
I just noticed that I'm getting loads of HEAD requests to my wrapped site, for the URL https://mywrappedsite.com/!gap_exec
Now, as far as I can tell, this isn't affecting the app - everything seems to be running OK, but I'm still seeing a bunch of these requests for each page load. Even if I comment out the injected script so that it doesn't do anything, I'm still seeing one hit per request.
Soooooo, it would appear that gap_exec
is something that cordova uses internally to talk to internal phone hardware, correct? (Source: http://stackoverflow.com/questions/16631230/phonegap-cordova-2-7-0-exec-gap-file-not-found)
So it looks like something is ammis here? I can see on the ios specific cordova.js, line 1016:
execXhr.open('HEAD', "/!gap_exec?" + (+new Date()), true);
Now, because that url is relative - / rather than file:// I can see why this potentially might upset things for a hosted web app.
Thoughts?
On my external page i have some javascript code that creates an event.
This event is caught by some javascript within my app.
Sometimes the app freezes completely.
// Workaround for Windows 10 in hosted environment case
// http://www.w3.org/html/wg/drafts/html/master/browsers.html#named-access-on-the-window-object
if (window.cordova && !(window.cordova instanceof HTMLElement)) {
throw new Error("cordova already defined");
}
Does this plugin currently support creating UWP projects for Win10? I noticed in the doc only Windows 8.1 is listed as supported.
See issue details in pwa-builder/PWABuilder-CLI#187
Cordova Android and iOS provide additional support to control which network requests triggered by the page in the webview (css, js, images, XHRs, etc) are allowed to be made; this means that any content requested by the page that does not belong to the whitelist will be blocked.
This is currently not supported by Windows
Is there any plans to support cordova ios 4.x ? What are the issues preventing this to work ?
Repro steps:
Expected result: custom message notifying the error
Actual result: The extended splash screen is never closed
Using VS 2015 with Cordova Tools, Cordova 6.1.1:
When running UWP Win 10 version of blank app with hostedwebapp plugin installed, a WinJS error pops up:
Unhandled exception at line 9, column 9 in ms-appx://[REMOVED]/www/js/wrapper.js
0x800a1391 - JavaScript runtime error: 'WinJS' is undefined
Workaround:
I've wrapped the whole content of wrapper.js into a window.load =function() { } block to make sure it's executed only when wapper.html has loaded.
Seems to do the trick.
Just wanted to make sure that this is a correct workaround.
Thanks!
Apparently, the network-information plugin always retrieves the same value in the connectionRequired property of the CDVReachability class when disabling or enabling wifi in a real device.
When building for ios, I get this warning:
The module "ConfigParser" has been factored into "cordova-common". Consider update your plugin hooks.
followed by this error:
Error: Cannot find module '../../node_modules/elementtree'
manifest.json is created before adding plugin and elementtree exists in platforms\ios\cordova\node_modules
Implement support for splash_screens member in the W3C manifest.
Since we already support splash screen images in the icons section of the manifest, any images under splash_screens will take precedence over similarly sized images in the icons section.
(see also pwa-builder/PWABuilder-CLI#45).
In Windows Phone 10, the extended splash screen image is not being properly scaled to fit into the screen, like the original splash screen does. This feature has been temporarily disabled (see 505256f) until it is fixed.
Take in and test upgrade to latest version of cordova
Even though a relative URL is a valid start_url according to the W3C spec, ManifoldCordova requires a full URL (because the plugin cannot determine the manifest's origin once it has been downloaded).
The plugin should validate this member and issue a suitable error message if it finds a relative URL. There should be also an initial check that the start_url member actually exists in the manifest, and if not show an appropriate error message.
Since the Windows platform does not support remote content on the app container natively, the ManifoldCordova plugin adds a WebView to the landing page to render the website content specified in the manifest.json.
The current drawback of this approach is that there is no communication between the JavaScript running on the webview and the native code of the plugins. For example, the JavaScript interface of the plugins is not executed in the webview, so the JavaScript methods exposed by the plugins are not available.
i'm using visual studio 2015 with Cordova tools installed (cordova 6.1.1). Have used Cordova CLI to add hosted webapp plugin. When trying to build Windows 10 UWP version, the build process is unable to copy wrapper.js to platforms/windows/www/js/ as the js folder does not exist.
Copying wrapper js file for the windows platform from E:[REMOVED]\plugins\cordova-plugin-hostedwebapp\assets\windows\wrapper.js to E:[REMOVED]\platforms\windows\www\js\wrapper.js.
1>MSBUILD : cordova-build error : [Error: ENOENT, open 'E:[REMOVED]\platforms\windows\www\js\wrapper.js']
My workaround:
I've updated "copyFile" function in replaceWindowsWrapperFiles.js to create the copy destination directory if it doesnt exist.
Just wanted to make sure I've not done anything wrong and my workaroudn was the correct workaround.
Thanks
For details about this issue please refer to pwa-builder/PWABuilder-CLI#156
given the following manifest.json
{
"start_url": "http://www.domain.com",
"scope": "http://*.domain.com"
}
The following invalid access rules are generated by the plugin hooks:
<access origin="http:///*" />
<allow-navigation href="http:///*" />
I have deployed the manifoldjs to some installations now and it is working fine!
However, for my project it would be really helpfull if the manifold shell could detect if a page change was correct, a.k.:
first, you are on page /test
then you reload page with (location.reload()), but the server has an issue and gives back 500,
* then the script waits 1 or 5 minutes, and retries to load page again. *
The same for other non-200 responses.
My scripts will no longer inject. I have no idea why... Is there any way to debug this?
Is it possible to load the local index.html first and then trigger when I want to load a choosen manifest file?
I think this is a bug, although there is a chance it's me misunderstanding something:
"icons": [
{
"src": "/content/images/mobile/icons/mdpi/harry.png",
"sizes": "48x48",
"type": "image/png"
},
{
"src": "/content/images/mobile/icons/hdpi/harry.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "/content/images/mobile/icons/xhdpi/harry.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "/content/images/mobile/icons/xxhdpi/harry.png",
"sizes": "144x144",
"type": "image/png"
}
],
Notice how the name is harry.png.
Now, when you do a cordova prepare
, the icons are downloaded and copied into the cordova folder into the correct paths, BUT when they get copied to the android res folder, they are all renamed to icon.png, which is at odds with the manifest and config.xml.
When you then run the resulting app (for me, on an android device), you don't see the specified icon, just the manifold logo. I'm assuming this is because it looked for, and failed to find harry.png?
On devices that don't support the evaluateJavascript
method on the WebView, the fallback using .loadUrl("javascript:" + ...)
doesn't properly work either.
E/Web Console: Uncaught SyntaxError: Unexpected token % at null:1
All special chars of the script are "percent encoded" by Uri.encode()
before being handed over to .loadUrl()
, which seems to cause this error. I.e. it will choke on spaces in the script (%20
) and such.
Simply removing the Uri.encode()
call seems to fix the problem:
https://github.com/manifoldjs/ManifoldCordova/blob/master/src/android/HostedWebApp.java#L550
me.webView.getEngine().loadUrl("javascript:" + scriptToInject, false);
Tested on Android Jelly Bean 4.3, Samsung Galaxy Nexus
I'm running the latest version of Cordova, which means I get deprecation warnings because this plugin requires very outdated versions of iOS and Android.
Installing "cordova-plugin-hostedwebapp" for android
Plugin doesn't support this project's cordova-android version. cordova-android: 5.1.1, failed version requirement: <=4.1.1
Skipping 'cordova-plugin-hostedwebapp' for android
Installing "cordova-plugin-hostedwebapp" for ios
Plugin doesn't support this project's cordova-ios version. cordova-ios: 4.1.1, failed version requirement: <=3.9.2
Skipping 'cordova-plugin-hostedwebapp' for ios
Any chance of getting this updated anytime soon?
This concern was raised in #23:
Currently, an offline overlay is automatically displayed when the connection is lost. However, there are scenarios when the page was properly loaded, and the user wants to continue seeing the content of the page even if the device is eventually disconnected.
The behavior should be reviewed so that:
We should look at the Cordova's ErrorUrl preference which might cover this scenario.
Hi and thanks for this nice plugin.
I have setup the plugin according to the tutorial.
I also included some plugins, for example the ionic-keyboard-plugin.
Now when I chrome://inspect on my device, cordova.plugins does not exist. It seems like the page is loaded without the plugins?
My manifest:
{
"lang": "en",
"name": "rd",
"short_name": "rd",
"icons": [{
"src": "icon/lowres",
"sizes": "64x64",
"type": "image/webp"
}, {
"src": "icon/hd_small",
"sizes": "64x64"
}, {
"src": "icon/hd_hi",
"sizes": "128x128",
"density": 2
}],
"scope": "/",
"start_url": "https://linkedin.com",
"display": "fullscreen",
"orientation": "landscape",
"theme_color": "aliceblue",
"mjs_api_access": { "match": "*", "platform": "android", "access": "cordova" }
}
The offline event works well!
I'm aware of hostedwebapp.disableOfflinePage(), but that only loads after deviceready has fired and I'm afraid that if a device is offline it will go to the offline page, before that this function is called.
When cordova-plugin-hostedwebapp is used together with cordova-plugin-statusbar, the WebView becomes non-interactive (cannot click on links/buttons/forms) and the scrolling breaks (somehow, scrollbars can appear).
The issue is present for any version of cordova-plugin-statusbar greater than 0.1.6 (older versions will work).
Removing this last line from createOfflineView
in CDVHostedWebApp.m
seems to solve the issue but there is probably a better fix to be done?
[self.viewController.view sendSubviewToBack:self.webView];
Moved from ManifoldJS (pwa-builder/PWABuilder-CLI#103)
There are some breaking changes in the Windows platform (cordova-windows 4.0.0) that need to be addressed in the plugin:
The repo for this plugin is called Manifold Cordova, and the plugin itself is called cordova-plugin-hostedwebapp
. This plugin is pretty useful for a general cordova app to detect network issues and display an offline page.
Please consider re-naming this plugin to cordova-plugin-offlinepage
to better reflect its purpose.
One of the hooks in this apps looks for a W3C Manifest.json. As a result, this plugin cannot be added to a regular Cordova hook.
Does it make sense to skip the manifest steps if such a file does not exist ? This way, the plugin can be added to Cordova also.
When pressing the back button, the app is closed instead of navigating to the previous page in the webview stack, similar to what cordova app for Android does.
Currently, this feature is present in the Web-App-ToolKit plugin. We should consider to move this feature to the ManifoldCordova plugin.
The If-Modified-Since HTTP header appears to be ignored when issuing multiple requests to the same resource.
In the before_prepare hook, calling downloadImage multiple times using the same inputUri always returns "200 OK" and downloads the image every time. It should return "304 - Not Modified" for subsequent requests.
This behavior can be seen in ManifoldJS which calls cordova add platform, cordova prepare, and cordova build in quick succession. Executing the same sequence from the command line works as expected.
We're building a mobile app using manifoldJS. On iOS, when we lose the network (e.g. airplane mode), and then re-connect, the app never returns from the offline status page.
Just to give you a bit more context, we're using these plugins:
cordova-plugin-crosswalk-webview 1.5.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.1.0 "Device"
cordova-plugin-hostedwebapp 0.2.1 "HostedWebApp"
cordova-plugin-network-information 1.1.0 "Network Information"
cordova-plugin-splashscreen 3.0.0 "Splashscreen"
cordova-plugin-statusbar 2.1.0 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
phonegap-plugin-push 1.4.4 "PushPlugin"
We have our own offline page. We're testing this on 2 separate iphones, an iphone 4 and 6, and see the same issue on both.
iOS version is latest: 9.2.1
The offline mode works fine on android.
Any ideas?
Error messages:
<TEST INDEX="49" NAME="UTF-8 file encoding" DESCRIPTION="Packages containing an HTML5 Windows Store app must have correct file encoding." EXECUTIONTIME="00h:00m:02s.29ms">
<RESULT><![CDATA[FAIL]]></RESULT>
<MESSAGES>
<MESSAGE TEXT="File D:\Projects\MyApps\WATDocs\platforms\windows\build\windows\debug\anycpu\AppX\www\js\wrapper.js is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte Order Mark)." />
<MESSAGE TEXT="File D:\Projects\MyApps\WATDocs\platforms\windows\build\windows\debug\anycpu\AppX\www\wrapper.html is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte Order Mark)." />
<MESSAGE TEXT="File D:\Projects\MyApps\WATDocs\platforms\windows\build\windows\debug\anycpu\AppX\www\css\wrapper.css is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte Order Mark)." />
</MESSAGES>
</TEST>
First of all, great work! I'm new to this mobile world, and Manifold has been providing something that I see as a very needed glue between Cordova and a hosted web app.
So, the problem is:
on Android, when I run the application on my device with Android Studio, if I have no Internet connection, the browser's default offline page will show instead of Cordova's default message or the custom offline.html.
Launching the app online and switching to offline works as expected though
Hi,
I have been testing your plugin, and i was wondering why is the cordova js object only available to me on window load?
window.load is too late for me :-(
Is there any special reason that your waiting for the web view finish load event to inject scripts?
Can they be injected earlier?
with Xcode 7 ,Cordova IOS 3.9.2 , IOS 9.2 , its keep giving error (white list rejection) on xcode console even though manifest.json has entry under mjs_extended_scope for that domain ending with "" and in config.xml domain has allow navigation plus access origin to "" .
even though xcode shows error page opens correctly in app. only problem on that page no cordova plugin is accessible.
Steps to reproduce:
$ manifoldjs http://www.microsoft.com -p ios
$ cd WwwMicrosoftCom/cordova/
$ cordova run ios
The end result looks something like below:
This happens, because the cross-origin resource access to download CSS files (and other resources) is blocked, which is caused by ManifoldCordova removing the "full access" rules that are created by cordova create
by default (see https://github.com/manifoldjs/ManifoldCordova/blob/8e5b457c1e16cfc9c56308c5d1f26e340f48ae62/scripts/updateConfigurationBeforePrepare.js#L139).
The best default security policy would be such that it is as close as possible to the security policy enforced in modern Web browsers and honors related standards like CORS and CSP.
Replace mjs_access_whitelist
with mjs_extended_scope
to make more clear the purpose of this setting (i.e. define multiple navigation scope rules).
Currently, on app startup, the sample content of the index.html page generated by cordova is shown a few seconds before the webview is created and the content of the target website is shown, which causes an odd experience.
Instead, a good alternative would be to present an "extended splash screen" to the user until the plugin completes the initialization phase.
Given the following manifest:
{
"start_url": "http://shiftr.azurewebsites.net",
"mjs_access_whitelist": [
{ "url": "https://github.com/aspnet/* }
]
}
Requests to https://github.com/aspnet should open inside the app (like in android and iOS)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.