Skip to content

Commit

Permalink
Added support for Override/AppendUserAgent in iOS, matching cordova-i…
Browse files Browse the repository at this point in the history
…os implementation

- Does have the same issues as apache#94
  • Loading branch information
Phil McCloghry-Laing committed Mar 2, 2016
1 parent 64c6365 commit 5e3d5df
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/ios/CDVThemeableBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ - (CDVThemeableBrowser*)initWithWebView:(UIWebView*)theWebView
return self;
}

- (id)settingForKey:(NSString*)key
{
return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
}

- (void)onReset
{
[self close:nil];
Expand Down Expand Up @@ -216,9 +221,18 @@ - (void)openInThemeableBrowser:(NSURL*)url withOptions:(NSString*)options
}

if (self.themeableBrowserViewController == nil) {
NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];
if (overrideUserAgent) {
userAgent = overrideUserAgent;
} else {
NSString* appendUserAgent = [self settingForKey:@"AppendUserAgent"];
if(appendUserAgent) {
userAgent = [userAgent stringByAppendingString: appendUserAgent];
}
}
self.themeableBrowserViewController = [[CDVThemeableBrowserViewController alloc]
initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent]
initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent]
browserOptions: browserOptions
navigationDelete:self
statusBarStyle:[UIApplication sharedApplication].statusBarStyle];
Expand Down

0 comments on commit 5e3d5df

Please sign in to comment.