@sajn/embed-react-native package. The package runs the signing page in a web view and opens eID pages and the BankID app for you.
Before you begin
- Follow Create a session on your server: your backend creates an embed session with your API key and returns its
clientSecret. - Pick the origin your app presents itself as, such as
https://app.example.com. Add it to your organization’s embed domains. The web view loads nothing from it; sajn only checks it.
Install the package
npx expo install react-native-webview for the native module.
Show the signing page
appearance.mode: "inline", it sizes itself to the content instead.
Props
SigningEmbed takes the same callbacks and the same host, appearance, locale and title as the web SDK, plus:
Changing
appearance or locale updates the frame in place. Changing host, title or debug reloads it.
eIDs in a native app
- Swedish BankID on the same phone: the frame hands the BankID link to
openUrl, and the BankID app opens. Set the session’sbankIdReturnUrlto your app’s URL scheme, such asmyapp://signed, so BankID brings the party back to your app. - MitID, FTN, Norwegian BankID and other eIDs that refuse frames: the frame hands the eID page to
openUrl. The party identifies in the browser, which ends on a page in your session’s colors and language, and returns to your app. The frame picks up the signature on its next status check, andonSignedfires.
Use a web view without React Native
In Swift or Kotlin, load a page that uses@sajn/embed-js with an openUrl option, and open the URLs it passes in the system browser:
- iOS (
WKWebView): load your page withloadHTMLString(_:baseURL:), with your embed origin asbaseURL. ForwardopenUrlcalls through aWKScriptMessageHandlerand open them withUIApplication.shared.open. InwebView(_:decidePolicyFor:decisionHandler:), allow subframe navigations, and send top-level navigations away from your page toUIApplication.shared.open. - Android (
WebView): load your page withloadDataWithBaseURL, with your embed origin as the base URL. ForwardopenUrlcalls through a@JavascriptInterfaceand open them with anIntent.ACTION_VIEW.
openUrl, the frame opens eID pages with window.open, which a web view ignores unless your app implements new windows.
