CB-3360: Set custom inappbrowser user agent for ios

This closes #94

Signed-off-by: Shazron Abdullah <shazron@gmail.com>
This commit is contained in:
Connor Pearson 2015-03-13 13:52:30 -04:00 committed by Shazron Abdullah
parent 768f886c6a
commit 4ef6106259
No known key found for this signature in database
GPG Key ID: 24C31ABCB01AAC82

View File

@ -47,6 +47,11 @@
_callbackIdPattern = nil; _callbackIdPattern = nil;
} }
- (id)settingForKey:(NSString*)key
{
return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
}
- (void)onReset - (void)onReset
{ {
[self close:nil]; [self close:nil];
@ -137,8 +142,16 @@
} }
if (self.inAppBrowserViewController == nil) { if (self.inAppBrowserViewController == nil) {
NSString* originalUA = [CDVUserAgentUtil originalUserAgent]; NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions]; NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];
NSString* appendUserAgent = [self settingForKey:@"AppendUserAgent"];
if(overrideUserAgent){
userAgent = overrideUserAgent;
}
if(appendUserAgent){
userAgent = [userAgent stringByAppendingString: appendUserAgent];
}
self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
self.inAppBrowserViewController.navigationDelegate = self; self.inAppBrowserViewController.navigationDelegate = self;
if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) { if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {