Created
August 20, 2019 14:28
-
-
Save iremlopsum/49d2dc758b9db49ee2be2316028c3bd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface SetupCallback { | |
/** | |
* @param { "0" | "1" | "2" } statusCode - Decides if registration through the native module was successful | |
* `"0"` - Registration was successful | |
* `"1"` - User canceled | |
* `"2"` - Registration failed | |
* | |
* @param { JSON } response - Response from the Amazon call that happens in the native module. Should include the following info: | |
* `authorizationCode`, | |
* `clientId`, | |
* `redirectURI` | |
* | |
* @param { string } verificationCode - code verifier that is generated by the LWA. Is used as a private key in the back end to access Amazon API | |
*/ | |
(statusCode: "0" | "1" | "2", response: JSON, verificationCode: string): void | |
} | |
class DRS { | |
/** | |
* @description Uses native LWA module to open either Amazon app or website | |
* Through which DRS registration happens. DRS registration values are returned through | |
* the `callback` | |
* | |
* @param { SetupCallback } callback - Used to return data from the native module | |
* @callback callback | |
*/ | |
startDRSSetup = async (callback: SetupCallback): Promise<void> => { | |
const deviceInfo = await comLayer.getDeviceConfiguration() | |
NativeModules.LWASharedModule.loginWithDeviceModel( | |
'Penguin', | |
deviceInfo.device_identifier, | |
true, | |
true, | |
callback, | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment