Skip to content

lsale/DRS-Sample-Cordova

DRS Teaser Page Sample for Cordova

Installing and running the DRS Teaser Page Sample for Cordova requires as little as 5 minutes.

1. Requirements

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

2. Installing the sample (2 mins)

  1. Clone the repository locally git clone https://github.com/lsale/DRS-Sample-Cordova.git
  2. Go into the newly cloned directory cd DRS-Sample-Cordova and run npm install

3. Adding Native support for iOS and Android

Adding Android support (1 to 10 mins)

Requirement: Android SDK must be available locally. Download it from the Android website.

  1. Add the Android platform: cordova platform add android

For help configuring the Android SDK with Cordova please refer to the official documentation

Adding iOS support (1 to 10 mins)

Requirement: Xcode must be installed. Download it from the Mac App Store.

  1. Add the iOS platform: cordova platform add ios

4. Installing the Cordova Plugin for Dash (1 to 5 mins)

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).

(Custom) Installing the plugin in a custom project (5 min installation)

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_KEY is the iOS API Key
  • BUNDLE_NAME is 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.

(Quick) Installing the plugin with sample credentials (1 min installation)

1. Install using the sample API credentials

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.eyJ2ZXIiOiIzIiwiZW5kcG9pbnRzIjp7ImF1dGh6IjoiaHR0cHM6Ly93d3cuYW1hem9uLmNvbS9hcC9vYS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BB6uMyRrQgROgA== --variable IOS_BUNDLE_NAME=com.amazon.drs.drsteaserpage

2. (Android only) - Add the API Key in your Android project

Copy the sample API_key.txt

  1. 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.

6. Running the DRS Teaser Page Sample for Cordova on your iOS and Android device

  1. Prepare
    • (iOS) Run cordova prepare ios.
    • (Android) Run cordova prepare android.
  2. Build
    • (iOS) Run cordova build ios
    • (Android) Run cordova build android --buildConfig=extras/build.json
  3. Run on a simulator or a real device
    • cordova run <PLATFORM> for example, cordova emulate android to run on your Android simulator.

Customize the Cordova Sample

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

About

A sample app to demonstrate DRS functionality

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENCE.md

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors