0

Description:

Built an app, need to implement Swedish BankID. This means, when user presses a button, the Swedish BankID App opens, and when the user has signed in, the Swedish BankID App sends the user back to my app (which it does automatically), in which I need to retrieve data (if sign in was successful or not).

What needs to be accomplished:

Open Swedish BankID on the device from my app. Need to be able to receive a payload from Swedish BankID App in my app (Swedish BankID sends user automatically back to my app).

Current Code:

const url = `https://app.bankid.com/?${autoStartToken}`;
            const supported = await Linking.canOpenURL(url);

            if (supported) {
                const answer = await Linking.openURL(url);
            } else {
                Alert.alert(`Don't know how to open this URL: ${url}`);
            }

Currently, the Swedish BankID App opens correctly, my question is, is there any way to receive data from the other app? I know this is possible with Native Modules (running Objective-C etc), however I am using Expo Client and do not wish to eject.

I have yet to find anything that suggests that React-Native can listen to the other app.

4

2 回答 2

0

您可以使用 expo WebBrowser打开 url。对于身份验证,您将需要使用 WebBrowser.openAuthSessionAsync,如果您只想打开网页 WebBrowser.openBrowserAsync 示例:

  ...
    import * as WebBrowser from 'expo-web-browser';
    ....
    
    const handleLinkAsync = async () => {
      let result = await WebBrowser.openBrowserAsync('https://google.com');
      console.log(result)
    };
于 2020-06-22T16:43:36.457 回答
0

由于 BankID 应用程序甚至可以在另一台设备上(如果您将 url 显示为 QR 码),因此很难与该应用程序通信。此外,从隐私的角度来看,该应用程序不应该泄露大量信息。

您可以做的是使用“重定向”参数通过应用程序“反弹”信息。当您想绑定到现有会话时,这特别有用。但是有一些注意事项,尤其是在使用多个浏览器时,因此请务必阅读依赖方指南

于 2020-06-23T05:57:05.307 回答