burstware / expo-plaid-link

Use the Plaid Link flow inside your expo app
MIT License
35 stars 20 forks source link

[BUG] Expo 43: "ERR_UNKNOWN_URL_SCHEME" when handling plaidlink:// #18

Closed AlexArendsen closed 2 years ago

AlexArendsen commented 2 years ago

Describe the bug

Getting this error when the webview navigates to a plaidlink:// location. Setting isWebview to false fixes it, however it also prevents me from intercepting events.

image

To Reproduce

Create an app using Plaid Link with Expo 43, run an Android emulator

Expected behavior

Plaid Link should open successfully

Screenshots

(please see above)

Expo (please complete the following information):

Smartphone (please complete the following information):

Additional context

I also have the react-native-plaid-link-sdk package installed from trying to do it Plaid's vanilla RN way. I'm using version 11.15.0 of react-native-webview.

AlexArendsen commented 2 years ago

Closing. In case anyone meanders down the long and winding road I just did:

  1. Amid my debugging, I had changed onShouldStartLoadWithRequest to onNavigationStateChange, which was causing the webview to attempt to load plaidlink:// URLs. It should, indeed, be onShouldStartLoadWithRequest, as it is in this repo.
  2. To add some additional stability, I wrapped the main guts of handleNavigationStateChange in a try/catch so that it will 100% always return false, eliminating any chance that the webview might accidentally try to fetch a plaidlink:// URL.
  3. Lastly, I updated originWhitelist={['*']} -- probably not necessary, but at this point I'm afraid to touch it any more 😅

Thanks so much for this package! It's a total life-saver for our team

Edit: one other piece of helpful feedback to devs: make sure you're providing a link token! That was the original cause for my problem here. For the repo, it would be nice if it were a bit more apparent when I haven't provided a link token-- maybe a console.warn or something, and for the component to return null until one is provided.