diff --git a/HVMobile_VNext-master/HVLib/Controllers/HVAppProvisionController.m b/HVMobile_VNext-master/HVLib/Controllers/HVAppProvisionController.m index 5134551..6fc7534 100755 --- a/HVMobile_VNext-master/HVLib/Controllers/HVAppProvisionController.m +++ b/HVMobile_VNext-master/HVLib/Controllers/HVAppProvisionController.m @@ -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]; @@ -150,4 +199,4 @@ -(NSString *)instanceIDFromQs:(NSString *)qs return [args objectForKey:@"instanceid"]; } -@end \ No newline at end of file +@end diff --git a/HVMobile_VNext-master/Samples/Demos/Health2.0/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist b/HVMobile_VNext-master/Samples/Demos/Health2.0/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist index 5860c3f..dae8aa6 100755 --- a/HVMobile_VNext-master/Samples/Demos/Health2.0/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist +++ b/HVMobile_VNext-master/Samples/Demos/Health2.0/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist @@ -2,6 +2,10 @@ + LSApplicationQueriesSchema + + bankid + CFBundleDevelopmentRegion en CFBundleDisplayName diff --git a/HVMobile_VNext-master/Samples/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist b/HVMobile_VNext-master/Samples/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist index fa6aa71..84cd55d 100755 --- a/HVMobile_VNext-master/Samples/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist +++ b/HVMobile_VNext-master/Samples/HelloHealthVault/HelloHealthVault/HelloHealthVault-Info.plist @@ -2,6 +2,21 @@ + CFBundleURLTypes + + + CFBundleURLName + com.company.appname + CFBundleURLSchemes + + myappname + + + + LSApplicationQueriesSchema + + bankid + CFBundleDevelopmentRegion en CFBundleDisplayName