Skip to content

Commit 5bfc340

Browse files
authored
Merge pull request #75 from Web3Auth/fix-android-demo-rn-bare
Fix Android redirectUrl issue in RN bare
2 parents a73c1ac + 17cef96 commit 5bfc340

File tree

4 files changed

+28
-257
lines changed

4 files changed

+28
-257
lines changed

demo/rn-bare-example/App.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Button,
77
ScrollView,
88
Dimensions,
9+
TextInput,
910
} from 'react-native';
1011
import * as WebBrowser from '@toruslabs/react-native-web-browser';
1112
import EncryptedStorage from 'react-native-encrypted-storage';
@@ -17,7 +18,7 @@ import Web3Auth, {
1718
} from '@web3auth/react-native-sdk';
1819
import RPC from './ethersRPC'; // for using ethers.js
1920

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

3133
const login = async () => {
3234
try {
@@ -42,7 +44,7 @@ export default function App() {
4244
mfaLevel: 'default',
4345
curve: 'secp256k1',
4446
extraLoginOptions: {
45-
login_hint: '[email protected]',
47+
login_hint: email,
4648
connection: 'email',
4749
},
4850
});
@@ -52,7 +54,7 @@ export default function App() {
5254
setKey(web3auth.privKey);
5355
uiConsole('Logged In');
5456
}
55-
} catch (e) {
57+
} catch (e: any) {
5658
setConsole(e.message);
5759
}
5860
};
@@ -136,7 +138,7 @@ export default function App() {
136138
uiConsole(message);
137139
};
138140

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

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

156158
const unloggedInView = (
157159
<View style={styles.buttonArea}>
160+
<TextInput
161+
editable
162+
onChangeText={text => setEmail(text)}
163+
value={email}
164+
// eslint-disable-next-line react-native/no-inline-styles
165+
style={{padding: 10}}
166+
/>
158167
<Button title="Login with Web3Auth" onPress={login} />
159168
</View>
160169
);

demo/rn-bare-example/android/app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
<action android:name="android.intent.action.MAIN" />
2121
<category android:name="android.intent.category.LAUNCHER" />
2222
</intent-filter>
23+
<intent-filter>
24+
<action android:name="android.intent.action.VIEW" />
25+
<category android:name="android.intent.category.DEFAULT" />
26+
<category android:name="android.intent.category.BROWSABLE" />
27+
<data android:scheme="web3authrnbareexample" />
28+
</intent-filter>
2329
</activity>
2430
</application>
2531
</manifest>

0 commit comments

Comments
 (0)