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.

Cevin Thomas
  • 387
  • 3
  • 14

2 Answers2

0

You can use expo WebBrowser to open url. For authentication you will want to use WebBrowser.openAuthSessionAsync, and if you just want to open a webpage WebBrowser.openBrowserAsync Exemple:

  ...
    import * as WebBrowser from 'expo-web-browser';
    ....
    
    const handleLinkAsync = async () => {
      let result = await WebBrowser.openBrowserAsync('https://google.com');
      console.log(result)
    };
Sergey Ivchenko
  • 1,497
  • 12
  • 11
0

Since the BankID app can even be on another device (if you present the url as a QR code) it's kind of hard to communicate with the app. Also, from a privacy perspective the app isn't supposed to give a lot of information away.

What you can do is to "bounce" information via the app using the "redirect" parameter. That's especially useful when you want to tie back to the existing session. There are however a few caveats, especially when using multiple browsers, so make sure to read the Relying Party Gudelines.

smuda
  • 101
  • 4
  • I understand, I am not sure If i need to have an "open communication" between them, I just need to know when the user gets redirected back to my app from the other app. Is there a way to set a redirect property on Linking? Also, is there a way listen to see if the user came back to the app? – Cevin Thomas Jun 23 '20 at 08:21
  • I don't think I understand what you're asking. Your app will need to register its own url scheme and supply that in the redirect parameter to the bankid app. After the user is done in the BankID app, your app will be called with the URL you supplied. You will need to detect being called by the url scheme and that way you'll know the user came back. – smuda Oct 11 '20 at 06:34