Skip to content

Commit 4057fdd

Browse files
authored
Merge pull request #3766 from bbirman/idp-config
Move off of deprecated openURL method
2 parents c441d2d + 74fb717 commit 4057fdd

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

libs/SalesforceSDKCore/SalesforceSDKCore/Classes/IDP/SFSDKIDPAuthHelper.m

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ + (void)invokeIDPApp:(SFSDKAuthSession *)session completion:(void (^)(BOOL))comp
6363

6464
NSURL *url = [command requestURL];
6565
dispatch_async(dispatch_get_main_queue(), ^{
66-
BOOL launched = [SFApplicationHelper openURL:url];
67-
completionBlock(launched);
66+
[SFApplicationHelper openURL:url options:@{} completionHandler:^(BOOL success) {
67+
completionBlock(success);
68+
}];
6869
});
6970
}
7071

@@ -95,8 +96,9 @@ + (void)invokeSPApp:(NSURL *)url completion:(void (^)(BOOL))completionBlock {
9596
[authWindow dismissWindow];
9697
[[[SFSDKWindowManager sharedManager] mainWindow:nil] presentWindow];
9798
}];
98-
BOOL launched = [SFApplicationHelper openURL:url];
99-
completionBlock(launched);
99+
[SFApplicationHelper openURL:url options:@{} completionHandler:^(BOOL success) {
100+
completionBlock(success);
101+
}];
100102
});
101103
}
102104

@@ -111,12 +113,15 @@ + (void)invokeSPAppWithError:(SFOAuthCredentials *)spAppCredentials error:(NSErr
111113
[authWindow dismissWindow];
112114
[[[SFSDKWindowManager sharedManager] mainWindow:nil] presentWindow];
113115
}];
114-
BOOL launched = [SFApplicationHelper openURL:url];
115-
if (!launched) {
116-
[SFSDKCoreLogger e:[self class] format:@"Could not launch spAPP to handle error %@",[error description]];
117-
}
118-
[[SFUserAccountManager sharedInstance] stopCurrentAuthentication:^(BOOL result) {
119-
[SFSDKCoreLogger d:[self class] format:@"Completed idp authentication with error, %@",error];
116+
117+
[SFApplicationHelper openURL:url options:@{} completionHandler:^(BOOL success) {
118+
if (!success) {
119+
[SFSDKCoreLogger e:[self class] format:@"Could not launch spAPP to handle error %@", [error description]];
120+
}
121+
122+
[[SFUserAccountManager sharedInstance] stopCurrentAuthentication:^(BOOL result) {
123+
[SFSDKCoreLogger d:[self class] format:@"Completed idp authentication with error, %@", error];
124+
}];
120125
}];
121126
});
122127
}

libs/SalesforceSDKCore/SalesforceSDKCore/Classes/URLHandlers/SFSDKStartURLHandler.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ - (BOOL)canHandleRequest:(NSURL *)url options:(NSDictionary *)options {
3838
- (BOOL)processRequest:(NSURL *)url options:(NSDictionary *)options {
3939
if (url) {
4040
dispatch_async(dispatch_get_main_queue(), ^{
41-
BOOL success = [SFApplicationHelper openURL:url];
42-
if (!success) {
43-
[SFSDKCoreLogger d:[self class] format:@"Could not launch %@", url];
44-
}
41+
[SFApplicationHelper openURL:url options:options completionHandler:^(BOOL success) {
42+
if (!success) {
43+
[SFSDKCoreLogger d:[self class] format:@"Could not launch %@", url];
44+
}
45+
}];
4546
});
4647
}
4748
return NO;

libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Util/SFApplicationHelper.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
#import <Foundation/Foundation.h>
26+
#import <SalesforceSDKCore/SalesforceSDKConstants.h>
2627

2728
NS_ASSUME_NONNULL_BEGIN
2829

@@ -43,7 +44,9 @@ NS_ASSUME_NONNULL_BEGIN
4344
@param url The URL to be opened.
4445
@return YES if the URL is successfully opened.
4546
*/
46-
+ (BOOL)openURL:(NSURL*)url;
47+
+ (BOOL)openURL:(NSURL*)url SFSDK_DEPRECATED(12.2, 13.0, "Use openURL:options:completionHandler: instead.");
48+
49+
+ (void)openURL:(NSURL*)url options:(NSDictionary<UIApplicationOpenExternalURLOptionsKey, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion;
4750

4851
@end
4952

libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Util/SFApplicationHelper.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,19 @@ + (BOOL)openURL:(NSURL*)url {
5151
return success;
5252
}
5353

54+
+ (void)openURL:(NSURL*)url options:(NSDictionary<UIApplicationOpenExternalURLOptionsKey, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion {
55+
UIApplication *app = [self sharedApplication];
56+
57+
if (app) {
58+
SEL selector = @selector(openURL:options:completionHandler:);
59+
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[app class] instanceMethodSignatureForSelector:selector]];
60+
[invocation setTarget:app];
61+
[invocation setSelector:selector];
62+
[invocation setArgument:&url atIndex:2];
63+
[invocation setArgument:&options atIndex:3];
64+
[invocation setArgument:&completion atIndex:4];
65+
[invocation invoke];
66+
}
67+
}
68+
5469
@end

native/SampleApps/RestAPIExplorer/RestAPIExplorer/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4444
SalesforceManager.shared.appDisplayName = "Rest API Explorer"
4545
UserAccountManager.shared.navigationPolicyForAction = { webView, action in
4646
if let url = action.request.url, url.absoluteString == "https://www.salesforce.com/us/company/privacy" {
47-
SFApplicationHelper.open(url)
47+
SFApplicationHelper.open(url, options: [:], completionHandler: nil)
4848
return .cancel
4949
}
5050
return .allow

0 commit comments

Comments
 (0)