{"action":"created","issue":{"url":"https://api.github.com/repos/manifoldjs/ManifoldJS/issues/156","labels_url":"https://api.github.com/repos/manifoldjs/ManifoldJS/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/manifoldjs/ManifoldJS/issues/156/comments","events_url":"https://api.github.com/repos/manifoldjs/ManifoldJS/issues/156/events","html_url":"https://github.com/manifoldjs/ManifoldJS/issues/156","id":106038393,"number":156,"title":"Support mobile-specific functionality","user":{"login":"mattwoberts","id":109196,"avatar_url":"https://avatars.githubusercontent.com/u/109196?v=3","gravatar_id":"","url":"https://api.github.com/users/mattwoberts","html_url":"https://github.com/mattwoberts","followers_url":"https://api.github.com/users/mattwoberts/followers","following_url":"https://api.github.com/users/mattwoberts/following{/other_user}","gists_url":"https://api.github.com/users/mattwoberts/gists{/gist_id}","starred_url":"https://api.github.com/users/mattwoberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattwoberts/subscriptions","organizations_url":"https://api.github.com/users/mattwoberts/orgs","repos_url":"https://api.github.com/users/mattwoberts/repos","events_url":"https://api.github.com/users/mattwoberts/events{/privacy}","received_events_url":"https://api.github.com/users/mattwoberts/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-09-11T15:51:18Z","updated_at":"2015-11-18T23:26:32Z","closed_at":null,"body":"A common scenario would be to create a wrapper for a hosted web app, and then compliment that by adding some additional things like push notifications support etc). I'm unsure what the process is when you want to do this - you can add for example the plugin for push notifications, and then add the code to allow this to www/js/index.js, but this code won't fire, since the launch URL is the hosted web app URL itself... \r\n\r\nFrom what I can see from reading around (http://code.tutsplus.com/tutorials/build-a-hosted-web-app-on-android-ios-and-windows-using-manifoldjs--cms-24444) it seems that the way to do this is to just add the cordova js files that are required directly to your web site, and then include them as script files in your html - am I on the right track here?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/manifoldjs/ManifoldJS/issues/comments/157897432","html_url":"https://github.com/manifoldjs/ManifoldJS/issues/156#issuecomment-157897432","issue_url":"https://api.github.com/repos/manifoldjs/ManifoldJS/issues/156","id":157897432,"user":{"login":"f2bo","id":1148767,"avatar_url":"https://avatars.githubusercontent.com/u/1148767?v=3","gravatar_id":"","url":"https://api.github.com/users/f2bo","html_url":"https://github.com/f2bo","followers_url":"https://api.github.com/users/f2bo/followers","following_url":"https://api.github.com/users/f2bo/following{/other_user}","gists_url":"https://api.github.com/users/f2bo/gists{/gist_id}","starred_url":"https://api.github.com/users/f2bo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f2bo/subscriptions","organizations_url":"https://api.github.com/users/f2bo/orgs","repos_url":"https://api.github.com/users/f2bo/repos","events_url":"https://api.github.com/users/f2bo/events{/privacy}","received_events_url":"https://api.github.com/users/f2bo/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T23:26:32Z","updated_at":"2015-11-18T23:26:32Z","body":"We've already made some progress that will allow the use of Cordova plugins in a hosted web app. We now support injecting Cordova and the plugin interface scripts into the pages of the hosted site. We're still working on this feature and it's not published yet, but if you're interested, you can start playing with it right now if you're willing to follow a few manual steps.\r\n\r\nYou can find detailed information about the new plugin support in this [wiki article](https://github.com/manifoldjs/ManifoldJS/wiki/Using-Cordova-Plugins-in-Hosted-Web-Apps). \r\n\r\nWe implemented two different plugin modes: _server_ and _client_. In '_client_'  mode, the **cordova.js** file and the plugin interface script files are retrieved from the app package. In '_server_' mode, these files are downloaded from the server along with the rest of the app's content. \r\n\r\nWe also implemented a mechanism for injecting scripts that can be used, among other things, to consume the plugins added to the app. Imported scripts can be retrieved from the app package or downloaded from a remote source.\r\n\r\nUntil ManifoldJS is updated to use the new features, you will need to manually replace the hosted web app plugin in your app. The wiki article provides a [Quick Start](https://github.com/manifoldjs/ManifoldJS/wiki/Using-Cordova-Plugins-in-Hosted-Web-Apps#quick-start) that explains the process.\r\n\r\nVery briefly, these are the steps that are needed to use plugins:\r\n\r\n- Add one or more Cordova plugins to the app.\r\n- Update the app's manifest to enable API access and to inject the Cordova runtime environment. The **match** attribute specifies the pages where you will use Cordova.\r\n\r\n  ```\r\n  {\r\n    ...\r\n    \"mjs_api_access\": [\r\n      { \"match\": \"http://yoursite.com/path1/*\", \"platform\": \"android;ios;windows\", \"access\": \"cordova\" },\r\n      ...\r\n    ]\r\n  }\r\n  ```\r\n- Optionally, choose a plugin mode. The default mode is _client_.\r\n\r\n    **Client mode**\r\n    ```\r\n    {\r\n    ...\r\n      \"mjs_cordova\": {\r\n        \"plugin_mode\": \"client\"\r\n      }\r\n    }\r\n    ```\r\n\r\n    **Server mode**\r\n    ```\r\n    {\r\n      ...\r\n      \"mjs_cordova\": {\r\n        \"plugin_mode\": \"server\",\r\n        \"base_url\": \"js/cordova\"\r\n      }\r\n    }\r\n    ```\r\n\r\n    (In '_server_' mode, the Cordova files and plugin interface scripts must be deployed to the site to the path specified in **base_url**. Also, the cordova.js and cordova_plugins.js files for each platform need to be renamed to specify the platform in their names so that **cordova.js** and **cordova_plugins.js** become, in the case of Android for example, **cordova-android.js** and **cordova_plugins-android.js** respectively.)\r\n\r\nTo inject scripts into the hosted web content:\r\n\r\n- Update the app's manifest to list the imported scripts.\r\n  ```\r\n  {\r\n    ...\r\n    \"mjs_import_scripts\": [\r\n      { \"src\": \"js/alerts.js\" },\r\n      { \"src\": \"http://yoursite.com/js/app/contacts.js\" },\r\n      { \"src\": \"js/camera.js\", \"match\": \"http://yoursite.com/profile/*\" },\r\n      ...\r\n    ]\r\n  }\r\n  ```\r\n\r\n- For app-hosted scripts, copy the script files to the Cordova project. The path in **mjs_import_scripts** must be specified relative to the '_www_' folder of the project. Server-hosted scripts must be deployed to the site."}}