Skip to content

[DEV-254944] Implementing a listener to handle the in-app browser closure in the alternative OAuth flow for the demo bank.#17

Open
pedroabdenor wants to merge 1 commit intomainfrom
DEV-254944-close-in-app-browser-alternative-flow
Open

[DEV-254944] Implementing a listener to handle the in-app browser closure in the alternative OAuth flow for the demo bank.#17
pedroabdenor wants to merge 1 commit intomainfrom
DEV-254944-close-in-app-browser-alternative-flow

Conversation

@pedroabdenor
Copy link
Collaborator

@pedroabdenor pedroabdenor commented Jan 16, 2025

Description

To ensure the in-app browser closes in the alternative OAuth flow of the demo bank, add the following code to the AppDelegate.mm in the iOS project:

#import <React/RCTLinkingManager.h>

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    return [RCTLinkingManager application:application openURL:url options:options];
}

At the end of the alternative flow, Trustly will call the URL Scheme provided by the merchant via the establish data, and the code above will capture this URL Scheme call and forward it to the React interface.

In the React code, the example code below should be added to capture the URL Scheme call and consequently close the in-app browser.

import {  Linking } from "react-native";

componentDidMount() {
  this.deepLinkEventListener = Linking.addEventListener('url', this.handleDeepLink);
}

componentWillUnmount() {
  this.deepLinkEventListener.remove() 
}

// Handle the deep link URL here
handleDeepLink = () => {
  InAppBrowser.closeAuth(); // Close the InAppBrowser when a deep link is detected
};

Note: We recommend running this example app at least once to understand how a transaction works through the OAuth flow. This code serves as an example of the logic to be followed for the proper functioning of the OAuth flow. Each merchant should consider their application's unique aspects when implementing it.


Requirements

  • Changes were properly tested (attach evidence if applicable)
  • Repository's code-style/linting compliant

Evidence

_ Not applicable


Additional Information

_Not applicable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants