$ npm install react-native-login-amz --save
or
$ yarn add react-native-login-amz
(RN <0.59)$ react-native link react-native-login-amz
- Add your api key to
Info.plist
(Instruction).
- Create
api_key.txt
inandroid/app/src/main/assets
and put you Amazon api key here (Instruction ).
import { useEffect } from "react";
import { Text, TouchableOpacity } from "react-native";
import LoginAmz from "react-native-login-amz";
const LoginAmzEventEmitter = new NativeEventEmitter(LoginAmz);
const Screen = () => {
useEffect(() => {
const handler = LoginAmzEventEmitter.addListener("LOGINAMZ", data => {
console.log("AMZ LOGIN", data);
if (data.status === "Ok") {
//
}
if (data.status === "Error") {
//
}
if (data.status === "Cancel") {
//
}
});
return () => {
handler.remove();
};
}, []);
return (
<TouchableOpacity onPress={() => LoginAmz.loginAMZ()}>
<Text>Login</Text>
</TouchableOpacity>
);
};