Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,55 @@ -(void)viewDidDisappear:(BOOL)animated

-(BOOL)webView: (UIWebView *)webView shouldStartLoadWithRequest: (NSURLRequest *)request navigationType: (UIWebViewNavigationType)navigationType
{
//Fix for using BankID with the correct CFBundleURLScheme to enable redirection from the
//BankID application back to the current application. Requires correct configuration in the Info.plist file
NSString *bankIDPrefix = @"bankid://";
NSString *bankIDSuffix = @"mg-local%2Fauth%2Fccp10%2Fgrp%2Fthis";
NSString *nullSuffix = @"redirect=null";

NSString *url = [[request URL] absoluteString];

BOOL bankidIsPresent = [url hasPrefix:bankIDPrefix];
BOOL nullIsPresent = [url hasSuffix:nullSuffix];
BOOL unspecifiedIsPresent = [url hasSuffix:bankIDSuffix];

if (bankidIsPresent && (nullIsPresent || unspecifiedIsPresent)) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *url = [request URL];

NSArray *bundleURLTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];

NSString *defaultURLScheme = @"null";

if(bundleURLTypes && bundleURLTypes.count > 0) {
NSDictionary *bundleURL = bundleURLTypes[0];

NSArray *URLScheme = [bundleURL objectForKey:@"CFBundleURLSchemes"];
NSString *URLSchemeDefinition = [URLScheme objectAtIndex:0];
NSLog(@"%@", URLSchemeDefinition);

if(URLSchemeDefinition != nil) {
defaultURLScheme = URLSchemeDefinition;
}
}

NSString *redirectString = [NSString stringWithFormat:@"redirect=%@://", defaultURLScheme];

NSString *subString = [[[url absoluteString] componentsSeparatedByString:@"redirect="] objectAtIndex:0];
subString = [subString stringByAppendingString:redirectString];
url = [NSURL URLWithString:subString];

NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSLog(@"%@", [url absoluteString]);

// reload the request
[self.webView loadRequest:request];
});
});
return NO;
}

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
[super webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];

Expand Down Expand Up @@ -150,4 +199,4 @@ -(NSString *)instanceIDFromQs:(NSString *)qs
return [args objectForKey:@"instanceid"];
}

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchema</key>
<array>
<string>bankid</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.company.appname</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myappname</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchema</key>
<array>
<string>bankid</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down