├── .gitignore ├── LICENSE ├── README.md ├── config.xml ├── dist └── android-release-signed.apk └── www ├── bower.json ├── icon.png ├── index.html └── manifest.json /.gitignore: -------------------------------------------------------------------------------- 1 | www/bower_components/ 2 | platforms/ 3 | plugins/ 4 | 5 | #MacOSX 6 | .DS_store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Andrew Dodson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hello.js and Cordova (Phonegap) Demo 2 | 3 | This is a demo implementation of [HelloJS](https://github.com/MrSwitch/hello.js/) within a Cordova app. 4 | 5 | [Hello.js](https://github.com/MrSwitch/hello.js) is a clientside javascript library to interface with thirdparty API's. 6 | 7 | 8 | ## Demo App 9 | 10 | [Android demo release .apk file](dist/android-release-signed.apk) 11 | 12 | 13 | ## Setup Demo 14 | 15 | It is assumed you are familiar with [cordova development](https://cordova.apache.org/). 16 | 17 | Here is your instructions: 18 | 19 | git clone git@github.com:MrSwitch/hellojs-phonegap-demo.git 20 | cd ./hellojs-phonegap-demo 21 | cordova plugin add cordova-plugin-inappbrowser 22 | cordova plugin add cordova-plugin-whitelist 23 | 24 | cd www 25 | bower install 26 | 27 | 28 | Next, simply add a platform and run e.g. 29 | 30 | cordova platform add ios 31 | cordova run ios 32 | 33 | # FAQ's 34 | 35 | * What's the difference with a typical browser? 36 | 37 | HelloJS in Cordova works slight differently because apps run off the local filesystem, not a registered web domain. When registering a `redirect_uri` with an OAuth2 provider we can't simply register a anonymous path like ~~`file://local_assets/redirect.html`~~ - pertaining to the origin of a cordova app. However we can register a legitimate domain, like `https://adodson.com/hello.js/redirect.html` and put that in its stead. On a browser this would not work, because the same-origin rule prevents a file:// path and a http:// path from talking to oneanother (amongst other things). 38 | However we're talking about the special world of in-app-browsers - not a typical browser environment. The cordova plugin InAppBrowser provides an interface in which HelloJS can launch the device's browser and provide an API to monitor and augment that web window. So HelloJS running in the Cordova app triggers the user signin flow, and listens for the right URI (aka value of `redirect_uri`) and extracts the query parameters, tokens, state, etc... 39 | 40 | * Does the Redirect page need to include HelloJS script 41 | 42 | No, unlike the browser environment its not neccesary for the Redirect page to contain an instance of the HelloJS library. In fact it doesn't actually need to return content at all. However there is a delay between loading the page and notifying the inappbrowser of the page load, a desolate white screen will appear to the user if nothing else. So think about pointing to a simple splash screen. 43 | 44 | * What to whitelist 45 | 46 | Cordova has some other quirks like requiring the HTTP requests to be whitelisted first. I've whitelist'ed the lot in config.xml file. 47 | 48 | 49 | 50 | 51 | 52 | ## Bugs 53 | 54 | If you encounter any bugs specifically with HelloJS, please create a ticket at the [Hello.js repo](https://github.com/MrSwitch/hello.js/) 55 | -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelloCordova 4 | 5 | A sample Apache Cordova application that responds to the deviceready event. 6 | 7 | 8 | Apache Cordova Team 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /dist/android-release-signed.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrSwitch/hellojs-phonegap-demo/0f8ffc2f8321e139698363311d8d853ace6c1765/dist/android-release-signed.apk -------------------------------------------------------------------------------- /www/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hellojs-phonegap", 3 | "version": "0.0.0", 4 | "authors": [ 5 | "Andrew Dodson " 6 | ], 7 | "description": "Build of Hello.js in PhoneGap", 8 | "license": "MIT", 9 | "homepage": "https://github.com/MrSwitch/hellojs-phonegap-demo/", 10 | "private": true, 11 | "ignore": [ 12 | "**/.*", 13 | "node_modules", 14 | "test", 15 | "tests" 16 | ], 17 | "dependencies": { 18 | "hello": ">=1", 19 | "adorn": "*" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /www/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrSwitch/hellojs-phonegap-demo/0f8ffc2f8321e139698363311d8d853ace6c1765/www/icon.png -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Hello JS 12 | 13 | 14 | 15 | 16 |

Demo: Hello.js in Cordova App

17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | Demo HelloJS with PhoneGap
25 | Signin above to view basic account details here
26 | 
27 | 28 | 31 | 32 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /www/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Andrew Dodson's web portfolio", 3 | "icons" : { 4 | "64" : "./icon.png" 5 | }, 6 | "root": "./", 7 | "favicon" : "./icon.png", 8 | "description" : "Andrew Dodson's portfolio", 9 | "github" : "MrSwitch/hellojs-phonegap-demo", 10 | "author" : "Andrew Dodson, https://adodson.com" 11 | } --------------------------------------------------------------------------------