Installing and running the DRS Teaser Page Sample for Cordova requires as little as 5 minutes.
To run this sample on iOS and Android, using the Amazon Dash Login Plugin (for Cordova), you will need to have Xcode and the Android SDK installed locally. To customize this project for your smart device you will need an Amazon Developer account. Create one or sign into an existing one at developer.amazon.com
- Clone the repository locally
git clone https://github.com/lsale/DRS-Sample-Cordova.git - Go into the newly cloned directory
cd DRS-Sample-Cordovaand runnpm install
Requirement: Android SDK must be available locally. Download it from the Android website.
- Add the Android platform:
cordova platform add android
For help configuring the Android SDK with Cordova please refer to the official documentation
Requirement: Xcode must be installed. Download it from the Mac App Store.
- Add the iOS platform:
cordova platform add ios
The amazon-dash-cordova-login-plugin provides you with access to the Login with Amazon Mobile SDK and Single-Sign-On functionality for customers who have the Amazon Shopping app installed (i.e. they won't need to type their username and password).
In the terminal, cd to your Cordova project directory and type cordova plugin add https://github.com/amzn/amazon-dash-cordova-login-plugin.git --variable IOS_API_KEY=<KEY> --variable IOS_BUNDLE_NAME=<PACKAGE_NAME>
Where:
API_KEYis the iOS API KeyBUNDLE_NAMEis the iOS bundle name (ex. com.myproject.myapp)
Instructions to customize the installation with your own API key and package name are available on the plugin github page.
If you haven't created an API key yet, and you just want to test out the sample, feel free to use the sample credentials and install the plugin as follows:
cordova plugin add https://github.com/amzn/amazon-dash-cordova-login-plugin.git --variable IOS_API_KEY=eyJhbGciOiJSU0EtU0hBMjU2IiwidmVyIjoiMSJ9.eyJ2ZXIiOiIzIiwiZW5kcG9pbnRzIjp7ImF1dGh6IjoiaHR0cHM6Ly93d3cuYW1hem9uLmNvbS9hcC9vYSIsInRva2VuRXhjaGFuZ2UiOiJodHRwczovL2FwaS5hbWF6b24uY29tL2F1dGgvbzIvdG9rZW4ifSwiY2xpZW50SWQiOiJhbXpuMS5hcHBsaWNhdGlvbi1vYTItY2xpZW50LmQ0MWQ2OWYxZGJiNTQ2MThhNzNlM2MwN2E1MDc0ZjNlIiwiYXBwRmFtaWx5SWQiOiJhbXpuMS5hcHBsaWNhdGlvbi5kYzQ4MWZmZGQ3OTM0NjY2YjBkNTdkYWExMGJiOTdlOCIsImJ1bmRsZVNlZWRJZCI6ImNvbS5hbWF6b24uZHJzLmRyc3RlYXNlcnBhZ2UiLCJidW5kbGVJZCI6ImNvbS5hbWF6b24uZHJzLmRyc3RlYXNlcnBhZ2UiLCJpc3MiOiJBbWF6b24iLCJ0eXBlIjoiQVBJS2V5IiwiYXBwVmFyaWFudElkIjoiYW16bjEuYXBwbGljYXRpb24tY2xpZW50LmViODZjMWE1MWIwYzRkOWE4ODM4NTE0NDg4OWQ4ZTA2IiwidHJ1c3RQb29sIjpudWxsLCJhcHBJZCI6ImFtem4xLmFwcGxpY2F0aW9uLWNsaWVudC5lYjg2YzFhNTFiMGM0ZDlhODgzODUxNDQ4ODlkOGUwNiIsImlkIjoiMTE3ZjMwYjMtZmZiZC0xMWU4LWI5OTItMTk4ZGQ5MTM3ZTRjIiwiaWF0IjoiMTU0NDgwNDgxNDIzMSJ9.jntLNSctn0/zOkFoeIEkoMPbcMSfUD2U6snrf0qsAljaG70HfvFgPa8VSIrMfhtEc1jzMWUuJW1M3ZM8mSC2B0RR3YBiu4K6mVdbZAeUaAjdUBFJmJAsfa9T+OixM+Fh6Bn/TYVPro4/DMFLzMv3rv4URifdIu+kpMwgQHYCJ8G7rFWLwfgPaCoNys0ADOz6iu3Yv++nU8xTnm8e3ekXvnA0RiXDa36cE2D+UeUw5yBlm4zyY54QmXnMwUc9nmcxPOUTOosiZh8CNokzsOShanisrZscBbwqy7W5eJOEyF3tIPYq4FeG234gJ754TTzksC6jwxhCBB6uMyRrQgROgA== --variable IOS_BUNDLE_NAME=com.amazon.drs.drsteaserpage
Copy the sample API_key.txt
- Run
cp extras/assets/api_key.txt platforms/android/app/src/main/assets/
The api_key.txt file contained in extras, uses Amazon test credentials. Refer to the "Customize the Cordova Sample" section if you wish to change it.
- Prepare
- (iOS) Run
cordova prepare ios. - (Android) Run
cordova prepare android.
- (iOS) Run
- Build
- (iOS) Run
cordova build ios - (Android) Run
cordova build android --buildConfig=extras/build.json
- (iOS) Run
- Run on a simulator or a real device
cordova run <PLATFORM>for example,cordova emulate androidto run on your Android simulator.
You can customize the sample by editing the PROJECT_DIRECTORY/www/js/index.js file with your deviceModel from your DRS console and the serial number that you will read from the DRS-enabled device.
Important: if you wish to change the deviceModel or the package/bundle name, you will have to generate your own API Key from your Security Profile and update:
- (iOS) APIKey entry in the iOS .plist file
- (Android) api_key.txt file