|
| 1 | +import React from "react" |
| 2 | +import { SafeAreaView, StyleSheet, Platform } from "react-native" |
| 3 | +import * as Linking from "expo-linking" |
| 4 | + |
| 5 | +import { ConnectWidget } from "@mxenabled/react-native-widget-sdk" |
| 6 | + |
| 7 | +const baseUrl = Platform.OS === "android" ? "http://10.0.2.2:8089" : "http://localhost:8089" |
| 8 | +const proxy = `${baseUrl}/user/widget_urls` |
| 9 | + |
| 10 | +const styles = StyleSheet.create({ |
| 11 | + page: { |
| 12 | + backgroundColor: "#ffffff", |
| 13 | + paddingTop: 10, |
| 14 | + }, |
| 15 | +}) |
| 16 | + |
| 17 | +export default function Connect() { |
| 18 | + const clientRedirectUrl = Linking.createURL("connect") |
| 19 | + |
| 20 | + return ( |
| 21 | + <SafeAreaView style={styles.page}> |
| 22 | + <ConnectWidget |
| 23 | + proxy={proxy} |
| 24 | + clientRedirectUrl={clientRedirectUrl} |
| 25 | + onSsoUrlLoadError={(error) => { |
| 26 | + console.error(`SSO URL load error: ${error}`) |
| 27 | + }} |
| 28 | + onMessage={(url) => { |
| 29 | + console.log(`Got a message: ${url}`) |
| 30 | + }} |
| 31 | + onInvalidMessageError={(url, _error) => { |
| 32 | + console.log(`Got an unknown message: ${url}`) |
| 33 | + }} |
| 34 | + onLoad={(_payload) => { |
| 35 | + console.log("Widget is loading") |
| 36 | + }} |
| 37 | + onLoaded={(_payload) => { |
| 38 | + console.log("Widget has loaded") |
| 39 | + }} |
| 40 | + onStepChange={(payload) => { |
| 41 | + console.log(`Moving from ${payload.previous} to ${payload.current}`) |
| 42 | + }} |
| 43 | + onSelectedInstitution={(payload) => { |
| 44 | + console.log(`Selecting ${payload.name}`) |
| 45 | + }} |
| 46 | + /> |
| 47 | + </SafeAreaView> |
| 48 | + ) |
| 49 | +} |
0 commit comments