The way people log in, register an app, and purchase content could be the difference between their becoming customers or not. In my recent blog post, I demonstrated what we have found to be a good login experience for customers using an Amazon Fire TV and remote control. In this second part, we’ll create a Cordova app which utilizes Login with Amazon via a third-party open source plugin.
There are a couple of steps we need to follow before we can start:
- Install the latest version of Cordova, here.
- Download the Android (not Cordova) Apps & Games SDK pack which contains the latest version of the Login with Amazon SDK. Unzip this somewhere for later.
- Install the latest Android SDK
7 steps to create an app with Cordova
1. Go to your working/projects folder and create the Cordova project:
# cordova create lwasample com.amazon.lwasample LWASample
This creates a folder called ‘lwasample,' generates a project with the app name ‘LWASample,’ and package name ‘com.amazon.lwasample.’
2. Add the Cordova platform Android for Fire TV Support
# cd lwasample
# cordova platform add android
3. Clone or download this third-party Login with Amazon Cordova plugin and add to the Cordova project
# cordova plugin add <path_to_plugin>
4. Copy the required libraries to your project
# cp <path_to_sdk_download>/login-with-amazon-sdk.jar platforms/android/libs/
Android support libraries found in the Android SDK:
# cp <path_to_android_sdk>/extras/android/support/v4/android-support-v4.jar /platforms/android/libs/
5. Generate the release and debug keys for signing the app
# keytool -genkey -v -keystore my-key.keystore -alias release -keyalg RSA -keysize 2048 -validity 10000
# keytool -genkey -v -keystore my-key.keystore -alias debug -keyalg RSA -keysize 2048 -validity 10000
We now need to get some information from the keystore by using the following command:
# keytool -list -v -alias debug -keystore my-key.keystore
From this command make the note of the MD5 and SHA256 signatures:
6. Create the security profiles
Click here and create a security profile for debug and release using the MD5 and SHA256 signatures obtained in step 5.
7. Paste the API keys into app config which should be created in config\project.json
For example, your config\project.json should look like this:
"AMAZON_API_KEY" : "eyJhbG......5csT=="
"AMAZON_API_KEY" : "df4Fsv......yc1A=="
Now the Login with Amazon plugin is set up and ready to go! The API can be used within your TV web app by using the following methods:
window.AmazonLogin.authorize(Object options, Function success, Function failure)
The success function will return a json object:
name: "Full Name",
A failure will return an error string.
window.AmazonLogin.signOut(Function success, Function failure)
To help you get started, a sample web app using Login with Amazon can be found here.
And, click here to read my first blog post on how to create a good TV app registration and login experience with Login with Amazon and Amazon In-App Purchasing.