You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/02/05 14:13:15 UTC
(cordova-plugin-inappbrowser) 01/01: fix(ios): use `cordovaSettingForKey:` instead of `objectForKey:`
This is an automated email from the ASF dual-hosted git repository.
manuelbeck pushed a commit to branch pr-ios-use-cordovaSettingForKey
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
commit bfb4b03c8ee527f55147c898fc49f2e8d84e0565
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Thu Feb 5 15:13:06 2026 +0100
fix(ios): use `cordovaSettingForKey:` instead of `objectForKey:`
- A custom method for getting a cordova setting is not needed, since `cordovaSettingForKey:` does already what is needed and lower cases the key before getting the value.
---
src/ios/CDVWKInAppBrowser.m | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index af39407..8731fb6 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -664,9 +664,9 @@ BOOL isExiting = FALSE;
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
NSString *userAgent = configuration.applicationNameForUserAgent;
- if ([self settingForKey:@"OverrideUserAgent"] == nil &&
- [self settingForKey:@"AppendUserAgent"] != nil) {
- userAgent = [NSString stringWithFormat:@"%@ %@", userAgent, [self settingForKey:@"AppendUserAgent"]];
+ if ([_settings cordovaSettingForKey:@"OverrideUserAgent"] == nil &&
+ [_settings cordovaSettingForKey:@"AppendUserAgent"] != nil) {
+ userAgent = [NSString stringWithFormat:@"%@ %@", userAgent, [_settings cordovaSettingForKey:@"AppendUserAgent"]];
}
configuration.applicationNameForUserAgent = userAgent;
@@ -689,7 +689,7 @@ BOOL isExiting = FALSE;
}
if (@available(iOS 13.0, *)) {
- NSString *contentMode = [self settingForKey:@"PreferredContentMode"];
+ NSString *contentMode = [_settings cordovaSettingForKey:@"PreferredContentMode"];
if ([contentMode isEqual: @"mobile"]) {
configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile;
} else if ([contentMode isEqual: @"desktop"]) {
@@ -829,8 +829,8 @@ BOOL isExiting = FALSE;
self.webView.navigationDelegate = self;
self.webView.UIDelegate = self.webViewUIDelegate;
self.webView.backgroundColor = [UIColor whiteColor];
- if ([self settingForKey:@"OverrideUserAgent"] != nil) {
- self.webView.customUserAgent = [self settingForKey:@"OverrideUserAgent"];
+ if ([_settings cordovaSettingForKey:@"OverrideUserAgent"] != nil) {
+ self.webView.customUserAgent = [_settings cordovaSettingForKey:@"OverrideUserAgent"];
}
self.webView.clearsContextBeforeDrawing = YES;
@@ -938,14 +938,6 @@ BOOL isExiting = FALSE;
}
}
-// Helper method to lowercase the key before getting the value from settings.
-// TODO: Can be replaced by calling `[_settings cordovaSettingForKey:]` which does this already.
-// cordovaSettingForKey: is available since cordova-ios 6 where NSDictionary+CordovaPreferences is used
-- (id)settingForKey:(NSString *)key
-{
- return [_settings objectForKey:[key lowercaseString]];
-}
-
- (void)setWebViewFrame:(CGRect)frame
{
NSLog(@"Setting the WebView's frame to %@", NSStringFromCGRect(frame));
@@ -999,7 +991,7 @@ BOOL isExiting = FALSE;
- (UIStatusBarStyle)preferredStatusBarStyle
{
- NSString *statusBarStylePreference = [self settingForKey:@"InAppBrowserStatusBarStyle"];
+ NSString *statusBarStylePreference = [_settings cordovaSettingForKey:@"InAppBrowserStatusBarStyle"];
if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"lightcontent"]) {
return UIStatusBarStyleLightContent;
} else if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"darkcontent"]) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org