BTAppContextSwitcher

Objective-C

@interface BTAppContextSwitcher : NSObject

Swift

class BTAppContextSwitcher : NSObject

Handles return URLs when returning from app context switch and routes the return URL to the correct app context switch driver class.

Note

returnURLScheme must contain your app’s registered URL Type that starts with the app’s bundle ID. When your app returns from app switch, the app delegate should call handleOpenURL: or handleOpenURLContext:
  • The URL scheme to return to this app after switching to another app or opening a SFSafariViewController.

    This URL scheme must be registered as a URL Type in the app’s info.plist, and it must start with the app’s bundle ID.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull returnURLScheme;

    Swift

    var returnURLScheme: String { get set }
  • The singleton instance

    Declaration

    Objective-C

    + (nonnull instancetype)sharedInstance;

    Swift

    class func sharedInstance() -> Self
  • Sets the return URL scheme for your app.

    This must be configured if your app integrates a payment option that may switch to either SFSafariViewController or to another app to finish the payment authorization workflow.

    Declaration

    Objective-C

    + (void)setReturnURLScheme:(nonnull NSString *)returnURLScheme;

    Swift

    class func setReturnURLScheme(_ returnURLScheme: String)

    Parameters

    returnURLScheme

    The return URL scheme

  • Handles a return from app context switch

    Declaration

    Objective-C

    + (BOOL)handleOpenURL:(nonnull NSURL *)url;

    Swift

    class func handleOpenURL(_ url: URL) -> Bool

    Parameters

    url

    The URL that was opened to return to your app

    Return Value

    YES if the app switch successfully handled the URL, or NO if the attempt to handle the URL failed.

  • Handles a return from app context switch

    Declaration

    Objective-C

    + (BOOL)handleOpenURLContext:(nonnull UIOpenURLContext *)URLContext;

    Swift

    class func handleOpenURLContext(_ URLContext: UIOpenURLContext) -> Bool

    Parameters

    URLContext

    The URLContext provided by scene:openURLContexts:

    Return Value

    YES if the app switch successfully handled the URLContext, or NO if the attempt to handle the URLContext failed.

  • Registers a class that knows how to handle a return from app context switch

    Declaration

    Objective-C

    - (void)registerAppContextSwitchDriver:
        (nonnull Class<BTAppContextSwitchDriver>)driver;

    Swift

    func register(_ driver: BTAppContextSwitchDriver.Type)