Skip to content

Commit a5c41ec

Browse files
committed
Update README.md
1 parent 1162d69 commit a5c41ec

File tree

1 file changed

+48
-63
lines changed

1 file changed

+48
-63
lines changed

README.md

Lines changed: 48 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ To allow the SDK to work with exported Expo Android apps, you need to place a de
6262
```js
6363
{
6464
"expo": {
65-
"scheme": "web3authreactnativesdkexample"
65+
"scheme": "web3authexposample"
6666
}
6767
}
6868
```
@@ -71,86 +71,71 @@ To allow the SDK to work with exported Expo Android apps, you need to place a de
7171

7272
When using our SDK with a bare workflow React Native app, you have to install a `WebBrowser` implementation made by us.
7373

74-
```bash npm2yarn
74+
```sh
7575
npm install --save @toruslabs/react-native-web-browser
7676
```
7777

7878
#### Android
7979

80-
- Perform the native [Android integration steps](https://web3auth.io/docs/sdk/android/).
81-
- For Android, the `redirectUrl` parameter is configurable, and has to be added into the `AndroidManifest.xml`.
80+
- The `scheme` parameter in the `redirectUrl` is specificable, and has to be added into the `AndroidManifest.xml`.
8281

83-
#### iOS
82+
```xml
83+
<data android:scheme="web3authrnexample" />
84+
```
8485

85-
- Perform the native [iOS integration steps](https://web3auth.io/docs/sdk/ios/).
86+
#### iOS
8687

87-
- You may add the `redirectUrl` to your iOS `Info.plist`, but it is not required.
88+
- The `scheme` parameter in the `redirectUrl` is specificable here as well, however, it does not need to be added as a iOS Custom URL Scheme. You may add the `scheme` to your iOS `Info.plist`, but it is not required.
8889

8990
#### Register the URL scheme you intended to use for redirection
9091

91-
- Android `AndoidManifest.xml` (required)
92-
- iOS `Info.plist` (optional)
92+
- In the Web3Auth Developer Dashboard, add the URL scheme you intended to use for redirection to the **Whitelist URLs** section.
9393

94+
For example, the scheme mentioned is `web3authrnexample` and the `redirectUrl` mentioned is `${scheme}://openlogin`, we will whitelist:
95+
96+
```
97+
web3authrnexample://openlogin
98+
```
9499

95100
## 💥 Initialization & Usage
96101

97102
In your sign-in activity', create an `Web3Auth` instance with your Web3Auth project's configurations and
98103
configure it like this:
99104

100-
```kotlin
101-
class MainActivity : AppCompatActivity() {
102-
// ...
103-
private lateinit var web3Auth: Web3Auth
104-
105-
override fun onCreate(savedInstanceState: Bundle?) {
106-
super.onCreate(savedInstanceState)
107-
setContentView(R.layout.activity_main)
108-
109-
web3Auth = Web3Auth(
110-
Web3AuthOptions(context = this,
111-
clientId = getString(R.string.web3auth_project_id),
112-
network = Web3Auth.Network.MAINNET,
113-
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
114-
whiteLabel = WhiteLabelData( // Optional param
115-
"Web3Auth Sample App", null, null, "en", true,
116-
hashMapOf(
117-
"primary" to "#123456"
118-
)
119-
)
120-
)
121-
)
122-
123-
// Handle user signing in when app is not alive
124-
web3Auth.setResultUrl(intent?.data)
125-
126-
// ...
127-
}
128-
129-
override fun onNewIntent(intent: Intent?) {
130-
super.onNewIntent(intent)
131-
132-
// Handle user signing in when app is active
133-
web3Auth.setResultUrl(intent?.data)
134-
135-
// ...
136-
}
137-
138-
private fun onClickLogin() {
139-
val selectedLoginProvider = Provider.GOOGLE // Can be Google, Facebook, Twitch etc
140-
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(LoginParams(selectedLoginProvider))
141-
142-
loginCompletableFuture.whenComplete { loginResponse, error ->
143-
if (error == null) {
144-
// render logged in UI
145-
} else {
146-
// render login error UI
147-
}
148-
149-
}
150-
}
151-
152-
//...
153-
}
105+
### Expo Managed Workflow
106+
107+
```js
108+
import * as WebBrowser from 'expo-web-browser';
109+
import Web3Auth, { LOGIN_PROVIDER, OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk";
110+
111+
const web3auth = new Web3Auth(WebBrowser, {
112+
clientId,
113+
network: OPENLOGIN_NETWORK.TESTNET, // or other networks
114+
});
115+
const info = await web3auth.login({
116+
loginProvider: LOGIN_PROVIDER.GOOGLE,
117+
redirectUrl: resolvedRedirectUrl,
118+
mfaLevel: 'mandatory', // optional
119+
curve: 'secp256k1', // optional
120+
});
121+
```
122+
123+
### Bare Workflow
124+
125+
```js
126+
import * as WebBrowser from '@toruslabs/react-native-web-browser';
127+
import Web3Auth, { LOGIN_PROVIDER, OPENLOGIN_NETWORK } from "@web3auth/react-native-sdk";
128+
129+
const web3auth = new Web3Auth(WebBrowser, {
130+
clientId,
131+
network: OPENLOGIN_NETWORK.TESTNET, // or other networks
132+
});
133+
const info = await web3auth.login({
134+
loginProvider: LOGIN_PROVIDER.GOOGLE,
135+
redirectUrl: resolvedRedirectUrl,
136+
mfaLevel: 'mandatory', // optional
137+
curve: 'secp256k1', // optional
138+
});
154139
```
155140

156141
## 🩹 Examples

0 commit comments

Comments
 (0)