Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android redirectUrl issue in RN bare #75

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions demo/rn-bare-example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Button,
ScrollView,
Dimensions,
TextInput,
} from 'react-native';
import * as WebBrowser from '@toruslabs/react-native-web-browser';
import EncryptedStorage from 'react-native-encrypted-storage';
Expand All @@ -17,7 +18,7 @@ import Web3Auth, {
} from '@web3auth/react-native-sdk';
import RPC from './ethersRPC'; // for using ethers.js

const scheme = 'web3authrnbareaggregateexample'; // Or your desired app redirection scheme
const scheme = 'web3authrnbareexample'; // Or your desired app redirection scheme
const resolvedRedirectUrl = `${scheme}://openlogin`;
const clientId =
'BHr_dKcxC0ecKn_2dZQmQeNdjPgWykMkcodEHkVvPMo71qzOV6SgtoN8KCvFdLN7bf34JOm89vWQMLFmSfIo84A';
Expand All @@ -27,6 +28,7 @@ export default function App() {
const [key, setKey] = useState<string | undefined>('');
const [console, setConsole] = useState<string>('');
const [web3auth, setWeb3Auth] = useState<IWeb3Auth | null>(null);
const [email, setEmail] = React.useState('[email protected]');

const login = async () => {
try {
Expand All @@ -42,7 +44,7 @@ export default function App() {
mfaLevel: 'default',
curve: 'secp256k1',
extraLoginOptions: {
login_hint: '[email protected]',
login_hint: email,
connection: 'email',
},
});
Expand All @@ -52,7 +54,7 @@ export default function App() {
setKey(web3auth.privKey);
uiConsole('Logged In');
}
} catch (e) {
} catch (e: any) {
setConsole(e.message);
}
};
Expand Down Expand Up @@ -136,7 +138,7 @@ export default function App() {
uiConsole(message);
};

const uiConsole = (...args) => {
const uiConsole = (...args: unknown[]) => {
setConsole(JSON.stringify(args || {}, null, 2) + '\n\n\n\n' + console);
};

Expand All @@ -155,6 +157,13 @@ export default function App() {

const unloggedInView = (
<View style={styles.buttonArea}>
<TextInput
editable
onChangeText={text => setEmail(text)}
value={email}
// eslint-disable-next-line react-native/no-inline-styles
style={{padding: 10}}
/>
<Button title="Login with Web3Auth" onPress={login} />
</View>
);
Expand Down
6 changes: 6 additions & 0 deletions demo/rn-bare-example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="web3authrnbareexample" />
</intent-filter>
</activity>
</application>
</manifest>
Loading