Register a URL type
- In Xcode, click on your project in the Project Navigator and navigate to App Target > Info > URL Types
- Click [+] to add a new URL type
- Under URL Schemes , enter your app switch return URL scheme. This scheme must start with your app’s Bundle ID and be dedicated to Braintree app switch returns . For example, if the app bundle ID is
com.your-company.Your-App
, then your URL scheme could becom.your-company.Your-App.payments
.
IMPORTANT
If you have multiple app targets, be sure to add the return URL type for all of the targets.
Testing the URL type
You can test out your new URL scheme by opening up a URL that starts with it (e.g. com.your-company.Your-App.payments://test
) in Mobile Safari on your iOS Device or Simulator.
In addition, always test your app switching on a real device.
Update your application delegate
In your AppDelegate’s application:didFinishLaunchingWithOptions:
implementation, use setReturnURLScheme:
with the value you set above.
#import “AppDelegate.h”
#import “BraintreeCore.h”
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[BTAppSwitch setReturnURLScheme:@“com.your-company.Your-App.payments”];
return YES;
}
hen in your application delegate, pass the payment authorization URL to Braintree for finalization:
Objective-CSwift
Copy
Copied
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
if ([url.scheme localizedCaseInsensitiveCompare:@"com.your-company.Your-App.payments"] == NSOrderedSame) {
return [BTAppSwitch handleOpenURL:url options:options];
}
return NO;
}