diff --git a/android/capacitor/src/main/java/com/getcapacitor/CapConfig.java b/android/capacitor/src/main/java/com/getcapacitor/CapConfig.java index b20799ba3..a000e24b9 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/CapConfig.java +++ b/android/capacitor/src/main/java/com/getcapacitor/CapConfig.java @@ -54,6 +54,7 @@ public class CapConfig { private String errorPath; private boolean zoomableWebView = false; private boolean resolveServiceWorkerRequests = true; + private String adjustMarginsForEdgeToEdge = "auto"; // Embedded private String startPath; @@ -286,6 +287,7 @@ private void deserializeConfig(@Nullable Context context) { webContentsDebuggingEnabled = JSONUtils.getBoolean(configJSON, "android.webContentsDebuggingEnabled", isDebug); zoomableWebView = JSONUtils.getBoolean(configJSON, "android.zoomEnabled", JSONUtils.getBoolean(configJSON, "zoomEnabled", false)); resolveServiceWorkerRequests = JSONUtils.getBoolean(configJSON, "android.resolveServiceWorkerRequests", true); + adjustMarginsForEdgeToEdge = JSONUtils.getString(configJSON, "android.adjustMarginsForEdgeToEdge", "auto"); String logBehavior = JSONUtils.getString( configJSON, @@ -582,6 +584,7 @@ public static class Builder { private int minHuaweiWebViewVersion = DEFAULT_HUAWEI_WEBVIEW_VERSION; private boolean zoomableWebView = false; private boolean resolveServiceWorkerRequests = true; + private String adjustMarginsForEdgeToEdge = "auto"; // Embedded private String startPath = null; diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java index 3f04adf97..d6cfe2e51 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java @@ -1,16 +1,9 @@ package com.getcapacitor.plugin; -import android.content.Context; import android.content.pm.PackageInfo; import android.content.res.Configuration; -import android.content.res.Resources; -import android.os.Build; -import android.util.TypedValue; import android.view.View; -import android.view.ViewGroup; import android.view.Window; -import android.webkit.JavascriptInterface; -import android.webkit.WebView; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowCompat; @@ -20,9 +13,10 @@ import com.getcapacitor.Plugin; import com.getcapacitor.PluginCall; import com.getcapacitor.PluginMethod; -import com.getcapacitor.WebViewListener; import com.getcapacitor.annotation.CapacitorPlugin; import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; @CapacitorPlugin public class SystemBars extends Plugin { @@ -33,9 +27,6 @@ public class SystemBars extends Plugin { static final String BAR_STATUS_BAR = "StatusBar"; static final String BAR_GESTURE_BAR = "NavigationBar"; - static final String INSETS_HANDLING_CSS = "css"; - static final String INSETS_HANDLING_DISABLE = "disable"; - static final String viewportMetaJSFunction = """ function capacitorSystemBarsCheckMetaViewport() { const meta = document.querySelectorAll("meta[name=viewport]"); @@ -46,55 +37,42 @@ function capacitorSystemBarsCheckMetaViewport() { const metaContent = meta[meta.length - 1].content; return metaContent.includes("viewport-fit=cover"); } + capacitorSystemBarsCheckMetaViewport(); """; - private boolean insetHandlingEnabled = true; - private boolean hasViewportCover = false; - - private String currentStyle = STYLE_DEFAULT; - @Override public void load() { - getBridge().getWebView().addJavascriptInterface(this, "CapacitorSystemBarsAndroidInterface"); super.load(); - initSystemBars(); } - @Override - protected void handleOnStart() { - super.handleOnStart(); - - this.getBridge().addWebViewListener( - new WebViewListener() { - @Override - public void onPageCommitVisible(WebView view, String url) { - super.onPageCommitVisible(view, url); - getBridge().getWebView().requestApplyInsets(); - } - } - ); - } + private boolean hasFixedWebView() { + PackageInfo packageInfo = WebViewCompat.getCurrentWebViewPackage(bridge.getContext()); + Pattern pattern = Pattern.compile("(\\d+)"); + Matcher matcher = pattern.matcher(packageInfo.versionName); - @Override - protected void handleOnConfigurationChanged(Configuration newConfig) { - super.handleOnConfigurationChanged(newConfig); + if (!matcher.find()) { + return false; + } - setStyle(currentStyle, ""); + String majorVersionStr = matcher.group(0); + int majorVersion = Integer.parseInt(majorVersionStr); + + return majorVersion >= 140; } private void initSystemBars() { String style = getConfig().getString("style", STYLE_DEFAULT).toUpperCase(Locale.US); boolean hidden = getConfig().getBoolean("hidden", false); + boolean disableCSSInsets = getConfig().getBoolean("disableInsets", false); - String insetsHandling = getConfig().getString("insetsHandling", "css"); - if (insetsHandling.equals(INSETS_HANDLING_DISABLE)) { - insetHandlingEnabled = false; - } - - initWindowInsetsListener(); - initSafeAreaInsets(); + this.bridge.getWebView().evaluateJavascript(viewportMetaJSFunction, (res) -> { + boolean hasMetaViewportCover = res.equals("true"); + if (!disableCSSInsets) { + setupSafeAreaInsets(this.hasFixedWebView(), hasMetaViewportCover); + } + }); getBridge().executeOnMainThread(() -> { setStyle(style, ""); @@ -138,72 +116,17 @@ public void setAnimation(final PluginCall call) { call.resolve(); } - @JavascriptInterface - public void onDOMReady() { - getActivity().runOnUiThread(() -> { - this.bridge.getWebView().evaluateJavascript(viewportMetaJSFunction, (res) -> { - hasViewportCover = res.equals("true"); - - getBridge().getWebView().requestApplyInsets(); - }); - }); - } - - private Insets calcSafeAreaInsets(WindowInsetsCompat insets) { - Insets safeArea = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()); - if (insets.isVisible(WindowInsetsCompat.Type.ime())) { - return Insets.of(safeArea.left, safeArea.top, safeArea.right, 0); - } - return Insets.of(safeArea.left, safeArea.top, safeArea.right, safeArea.bottom); - } - - private void initSafeAreaInsets() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM && insetHandlingEnabled) { - View v = (View) this.getBridge().getWebView().getParent(); - WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(v); - if (insets != null) { - Insets safeAreaInsets = calcSafeAreaInsets(insets); - injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left); + private void setupSafeAreaInsets(boolean hasFixedWebView, boolean hasMetaViewportCover) { + ViewCompat.setOnApplyWindowInsetsListener((View) getBridge().getWebView().getParent(), (v, insets) -> { + if (hasFixedWebView && hasMetaViewportCover) { + return insets; } - } - } - private void initWindowInsetsListener() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM && insetHandlingEnabled) { - ViewCompat.setOnApplyWindowInsetsListener((View) getBridge().getWebView().getParent(), (v, insets) -> { - boolean hasBrokenWebViewVersion = getWebViewMajorVersion() <= 139; - - if (hasViewportCover) { - Insets safeAreaInsets = calcSafeAreaInsets(insets); - injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left); - } - - if (hasBrokenWebViewVersion) { - if (hasViewportCover && v.hasWindowFocus() && v.isShown()) { - boolean keyboardVisible = insets.isVisible(WindowInsetsCompat.Type.ime()); - if (keyboardVisible) { - Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime()); - setViewMargins(v, Insets.of(0, 0, 0, imeInsets.bottom)); - } else { - setViewMargins(v, Insets.NONE); - } - - return WindowInsetsCompat.CONSUMED; - } - } + Insets safeArea = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()); + injectSafeAreaCSS(safeArea.top, safeArea.right, safeArea.bottom, safeArea.left); - return insets; - }); - } - } - - private void setViewMargins(View v, Insets insets) { - ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); - mlp.leftMargin = insets.left; - mlp.bottomMargin = insets.bottom; - mlp.rightMargin = insets.right; - mlp.topMargin = insets.top; - v.setLayoutParams(mlp); + return WindowInsetsCompat.CONSUMED; + }); } private void injectSafeAreaCSS(int top, int right, int bottom, int left) { @@ -239,8 +162,6 @@ private void injectSafeAreaCSS(int top, int right, int bottom, int left) { } private void setStyle(String style, String bar) { - currentStyle = style; - if (style.equals(STYLE_DEFAULT)) { style = getStyleForTheme(); } @@ -254,8 +175,6 @@ private void setStyle(String style, String bar) { if (bar.isEmpty() || bar.equals(BAR_GESTURE_BAR)) { windowInsetsControllerCompat.setAppearanceLightNavigationBars(!style.equals(STYLE_DARK)); } - - getActivity().getWindow().getDecorView().setBackgroundColor(getThemeColor(getContext(), android.R.attr.windowBackground)); } private void setHidden(boolean hide, String bar) { @@ -287,22 +206,4 @@ private String getStyleForTheme() { } return STYLE_DARK; } - - public int getThemeColor(Context context, int attrRes) { - TypedValue typedValue = new TypedValue(); - - Resources.Theme theme = context.getTheme(); - theme.resolveAttribute(attrRes, typedValue, true); - return typedValue.data; - } - - private Integer getWebViewMajorVersion() { - PackageInfo info = WebViewCompat.getCurrentWebViewPackage(getContext()); - if (info != null && info.versionName != null) { - String[] versionSegments = info.versionName.split("\\."); - return Integer.valueOf(versionSegments[0]); - } - - return 0; - } } diff --git a/cli/src/declarations.ts b/cli/src/declarations.ts index 6612eec77..dbb5a326a 100644 --- a/cli/src/declarations.ts +++ b/cli/src/declarations.ts @@ -707,17 +707,11 @@ export interface PluginsConfig { */ SystemBars?: { /** - * Specifies how to handle problematic insets on Android. + * Disables the injection of device css insets into the web view. * - * This option is only supported on Android. - * - * `css` = Injects CSS variables (`--safe-area-inset-*`) containing correct safe area inset values into the webview. - * - * `disable` = Disable all inset handling. - * - * @default "css" + * @default false */ - insetsHandling?: 'css' | 'disable'; + disableInsets?: boolean; /** * The style of the text and icons of the system bars. * diff --git a/core/package.json b/core/package.json index 74b7fc185..0570a0dd0 100644 --- a/core/package.json +++ b/core/package.json @@ -28,7 +28,7 @@ "build": "npm run clean && npm run docgen && npm run transpile && npm run rollup", "build:nativebridge": "tsc native-bridge.ts --target es2017 --moduleResolution node --outDir build && rollup --config rollup.bridge.config.js", "clean": "rimraf dist", - "docgen": "docgen --api CapacitorCookiesPlugin --output-readme cookies.md && docgen --api CapacitorHttpPlugin --output-readme http.md && docgen --api SystemBarsPlugin --output-readme system-bars.md", + "docgen": "docgen --api CapacitorCookiesPlugin --output-readme cookies.md && docgen --api CapacitorHttpPlugin --output-readme http.md && docgen --api SystemBarsPlugin --output-readme systembars.md", "prepublishOnly": "npm run build", "rollup": "rollup --config rollup.config.js", "transpile": "tsc", diff --git a/core/src/core-plugins.ts b/core/src/core-plugins.ts index a1efe9c90..ff18c19d3 100644 --- a/core/src/core-plugins.ts +++ b/core/src/core-plugins.ts @@ -617,14 +617,14 @@ export interface SystemBarsPlugin { * * @since 8.0.0 */ - show(options?: SystemBarsVisibilityOptions): Promise; + show(options: SystemBarsVisibilityOptions): Promise; /** * Hide the system bars. * * @since 8.0.0 */ - hide(options?: SystemBarsVisibilityOptions): Promise; + hide(options: SystemBarsVisibilityOptions): Promise; /** * Set the animation to use when showing / hiding the status bar. diff --git a/core/systembars.md b/core/systembars.md new file mode 100644 index 000000000..812472eb9 --- /dev/null +++ b/core/systembars.md @@ -0,0 +1,259 @@ +# SystemBars + +The SystemBars API provides methods for configuring the style and visibility of the device System Bars / Status Bar. This API differs from the [Status Bar](https://capacitorjs.com/docs/apis/status-bar) plugin in that it is only intended to support modern edge to edge use cases moving forward. For legacy functionality, use the [Status Bar](https://capacitorjs.com/docs/apis/status-bar) plugin. + +| Feature | System Bars | Status Bar | +| ------- | ----------- | ---------- | +| `setOverlaysWebView()` | Unsupported | Supported on iOS and Android <= 14 (or 15 if edge to edge opt-out is enabled) | +| `setBackgroundColor()` | Unsupported | Supported | +| `setStyle()` | Supported | Supported - top Status Bar only | +| `hide()/show()` | Supported | Supported - top Status Bar only | + +## iOS Note + +This plugin requires "View controller-based status bar appearance" +(`UIViewControllerBasedStatusBarAppearance`) set to `YES` in `Info.plist`. Read +about [Configuring iOS](https://capacitorjs.com/docs/ios/configuration) for +help. + +The status bar visibility defaults to visible and the style defaults to +`Style.Default`. You can change these defaults by adding +`UIStatusBarHidden` and/or `UIStatusBarStyle` in `Info.plist`. + +## Android Note + +Due to a [bug](https://issues.chromium.org/issues/40699457) in some older versions of Android WebView (< 140), correct safe area values are not available via the `safe-area-inset-x` CSS `env` variables. This plugin will inject the correct inset values into a new CSS variable(s) named `--safe-area-inset-x` that you can use as a fallback in your frontend styles: + +```css +html { + padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); + padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); + padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px)); + padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px)); +} +``` + +To disable the inset variable injections, set the configuration setting `disableInsets` to `true`. + +## Example + +```typescript +import { SystemBars, SystemBarsStyle } from '@capacitor/core'; + +const setSystemBarStyleDark = async () => { + await SystemBars.setStyle({ style: SystemBarsStyle.Dark }); +}; + +const setSystemBarStyleLight = async () => { + await SystemBars.setStyle({ style: SystemBarsStyle.Light }); +}; + +const hideSystemBars = async () => { + await SystemBars.hide(); +}; + +const showSystemBars = async () => { + await SystemBars.show(); +}; + +const hideNavigationBar = async () => { + await SystemBars.hide({ + bar: SystemBarType.NavigationBar + }) +} + +// Set the Status Bar animation, only on iOS +const setStatusBarAnimation = async () => { + await SystemBars.setAnimation({ animation: "NONE" }); +} + +```` + +## Configuration +| Prop | Type | Description | Default | +| ------------- | -------------------- | ------------------------------------------------------------------------- | ------------------ | +| **`disableInsets`** | boolean | Disables the injection of device css insets into the webview. This option is only supported on Android. | false | +| **`style`** | string | The style of the text and icons of the system bars. | DEFAULT | +| **`hidden`** | boolean | Hide the system bars on start. | false | +| **`animation`** | string | The type of status bar animation used when showing or hiding. This option is only supported on iOS. | FADE | + + +### Example Configuration + +In `capacitor.config.json`: + +```json +{ + "plugins": { + "SystemBars": { + "disableInsets": true, + "style": "DARK", + "hidden": false, + "animation": "NONE" + } + } +} +``` + +In `capacitor.config.ts`: + +```ts +import { CapacitorConfig } from '@capacitor/cli'; + +const config: CapacitorConfig = { + plugins: { + SystemBars: { + disableInsets: true, + style: "DARK", + hidden: false, + animation: "NONE" + }, + }, +}; + +export default config; +``` + +## API + + + +* [`setStyle(...)`](#setstyle) +* [`show(...)`](#show) +* [`hide(...)`](#hide) +* [`setAnimation(...)`](#setanimation) +* [Interfaces](#interfaces) +* [Type Aliases](#type-aliases) +* [Enums](#enums) + + + + + + +### setStyle(...) + +```typescript +setStyle(options: SystemBarsStyleOptions) => Promise +``` + +Set the current style of the system bars. + +| Param | Type | +| ------------- | ------------------------------------------------------------------------- | +| **`options`** | SystemBarsStyleOptions | + +**Since:** 8.0.0 + +-------------------- + + +### show(...) + +```typescript +show(options: SystemBarsVisibilityOptions) => Promise +``` + +Show the system bars. + +| Param | Type | +| ------------- | ----------------------------------------------------------------------------------- | +| **`options`** | SystemBarsVisibilityOptions | + +**Since:** 8.0.0 + +-------------------- + + +### hide(...) + +```typescript +hide(options: SystemBarsVisibilityOptions) => Promise +``` + +Hide the system bars. + +| Param | Type | +| ------------- | ----------------------------------------------------------------------------------- | +| **`options`** | SystemBarsVisibilityOptions | + +**Since:** 8.0.0 + +-------------------- + + +### setAnimation(...) + +```typescript +setAnimation(options: SystemBarsAnimationOptions) => Promise +``` + +Set the animation to use when showing / hiding the status bar. + +Only available on iOS. + +| Param | Type | +| ------------- | --------------------------------------------------------------------------------- | +| **`options`** | SystemBarsAnimationOptions | + +**Since:** 8.0.0 + +-------------------- + + +### Interfaces + + +#### SystemBarsStyleOptions + +| Prop | Type | Description | Default | Since | +| ----------- | ----------------------------------------------------------- | ----------------------------------------------- | ---------------------- | ----- | +| **`style`** | SystemBarsStyle | Style of the text and icons of the system bars. | 'DEFAULT' | 8.0.0 | +| **`bar`** | SystemBarType | The system bar to which to apply the style. | null | 8.0.0 | + + +#### SystemBarsVisibilityOptions + +| Prop | Type | Description | Default | Since | +| --------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------------------- | ----- | +| **`bar`** | SystemBarType | The system bar to hide or show. | null | 8.0.0 | +| **`animation`** | SystemBarsAnimation | The type of status bar animation used when showing or hiding. This option is only supported on iOS. | 'FADE' | 8.0.0 | + + +#### SystemBarsAnimationOptions + +| Prop | Type | Description | Default | Since | +| --------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------------------- | ----- | +| **`animation`** | SystemBarsAnimation | The type of status bar animation used when showing or hiding. This option is only supported on iOS. | 'FADE' | 8.0.0 | + + +### Type Aliases + + +#### SystemBarsAnimation + +Available status bar animations. iOS only. + +'FADE' | 'NONE' + + +### Enums + + +#### SystemBarsStyle + +| Members | Value | Description | Since | +| ------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- | +| **`Dark`** | 'DARK' | Light system bar content on a dark background. | 8.0.0 | +| **`Light`** | 'LIGHT' | For dark system bar content on a light background. | 8.0.0 | +| **`Default`** | 'DEFAULT' | The style is based on the device appearance or the underlying content. If the device is using Dark mode, the system bars content will be light. If the device is using Light mode, the system bars content will be dark. | 8.0.0 | + + +#### SystemBarType + +| Members | Value | Description | Since | +| ------------------- | ---------------------------- | ------------------------------------------------------------------- | ----- | +| **`StatusBar`** | 'StatusBar' | The top status bar on both Android and iOS. | 8.0.0 | +| **`NavigationBar`** | 'NavigationBar' | The navigation bar (or gesture bar on iOS) on both Android and iOS. | 8.0.0 | + + diff --git a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h index 171dbb463..ac52df02f 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h +++ b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.h @@ -13,6 +13,7 @@ NS_SWIFT_NAME(InstanceConfiguration) @property (nonatomic, readonly, nonnull) NSArray *allowedNavigationHostnames; @property (nonatomic, readonly, nonnull) NSURL *localURL; @property (nonatomic, readonly, nonnull) NSURL *serverURL; +@property (nonatomic, readonly, nullable) NSURL *configURL; @property (nonatomic, readonly, nullable) NSString *errorPath; @property (nonatomic, readonly, nonnull) NSDictionary *pluginConfigurations; @property (nonatomic, readonly) BOOL loggingEnabled; diff --git a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m index d6b7785e3..ed5125b0b 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m +++ b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.m @@ -49,6 +49,13 @@ - (instancetype)initWithDescriptor:(CAPInstanceDescriptor *)descriptor isDebug:( else { _serverURL = _localURL; } + + if (descriptor.configUrl != nil) { + _configURL = descriptor.configUrl; + } + else { + _configURL = [[NSURL alloc] initWithString:(@"capacitor.config.json")]; + } _errorPath = descriptor.errorPath; // extract the one value we care about from the cordova configuration _cordovaDeployDisabled = [descriptor cordovaDeployDisabled]; diff --git a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h index f477ef55b..d4d02203d 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h +++ b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.h @@ -68,6 +68,11 @@ NS_SWIFT_NAME(InstanceDescriptor) @discussion Defaults to nil, in which case the server URL will be constructed from @c urlScheme and @c urlHostname. If set, it will override the other properties. Set by @c server.url in the configuration file. */ @property (nonatomic, copy, nullable) NSString *serverURL; +/** + @brief The file URL from which Capacitor will load configuration + @discussion Defaults to @c capacitor.config.json located at the root of the application bundle. + */ +@property (nonatomic, copy, nullable) NSURL *configUrl; /** @brief The JSON dictionary that contains the plugin-specific configuration information. @discussion Set by @c plugins in the configuration file. diff --git a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift index a7eff5f62..db8c8f7d4 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift +++ b/ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift @@ -30,6 +30,8 @@ internal extension InstanceDescriptor { // swiftlint:disable function_body_length // swiftlint:disable:next identifier_name @objc func _parseConfiguration(at capacitorURL: URL?, cordovaConfiguration cordovaURL: URL?) { + configUrl = capacitorURL + // sanity check that the app directory is valid var isDirectory: ObjCBool = ObjCBool(false) if warnings.contains(.missingAppDir) == false, diff --git a/ios/Capacitor/Capacitor/CapacitorBridge.swift b/ios/Capacitor/Capacitor/CapacitorBridge.swift index 7b8b9b99d..81b1e6cca 100644 --- a/ios/Capacitor/Capacitor/CapacitorBridge.swift +++ b/ios/Capacitor/Capacitor/CapacitorBridge.swift @@ -305,9 +305,9 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol { func registerPlugins() { var pluginList: [AnyClass] = [CAPHttpPlugin.self, CAPConsolePlugin.self, CAPWebViewPlugin.self, CAPCookiesPlugin.self, CAPSystemBarsPlugin.self] - if autoRegisterPlugins { + if autoRegisterPlugins && config.configURL != nil { do { - if let pluginJSON = Bundle.main.url(forResource: "capacitor.config", withExtension: "json") { + if let pluginJSON = Bundle.main.url(forResource: (config.configURL!.path as NSString).deletingPathExtension, withExtension: "json") { let pluginData = try Data(contentsOf: pluginJSON) let registrationList = try JSONDecoder().decode(RegistrationList.self, from: pluginData) diff --git a/ios/Capacitor/Capacitor/Plugins/SystemBars.swift b/ios/Capacitor/Capacitor/Plugins/SystemBars.swift index 2c7d6753c..f4935e487 100644 --- a/ios/Capacitor/Capacitor/Plugins/SystemBars.swift +++ b/ios/Capacitor/Capacitor/Plugins/SystemBars.swift @@ -5,10 +5,10 @@ public class CAPSystemBarsPlugin: CAPPlugin, CAPBridgedPlugin { public let identifier = "CAPSystemBarsPlugin" public let jsName = "SystemBars" public let pluginMethods: [CAPPluginMethod] = [ - CAPPluginMethod(name: "setStyle", returnType: CAPPluginReturnPromise), - CAPPluginMethod(name: "setAnimation", returnType: CAPPluginReturnPromise), - CAPPluginMethod(name: "show", returnType: CAPPluginReturnPromise), - CAPPluginMethod(name: "hide", returnType: CAPPluginReturnPromise) + CAPPluginMethod(name: "setStyle", returnType: CAPPluginReturnNone), + CAPPluginMethod(name: "setAnimation", returnType: CAPPluginReturnNone), + CAPPluginMethod(name: "show", returnType: CAPPluginReturnNone), + CAPPluginMethod(name: "hide", returnType: CAPPluginReturnNone) ] public private(set) var hideHomeIndicator: Bool = false