Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ Remove all native listeners for this plugin.

Represents the options passed to `open`.

| Prop | Type | Description | Since |
| ----------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| **`url`** | <code>string</code> | The URL to which the browser is opened. | 1.0.0 |
| **`windowName`** | <code>string</code> | Web only: Optional target for browser open. Follows the `target` property for window.open. Defaults to _blank. Ignored on other platforms. | 1.0.0 |
| **`toolbarColor`** | <code>string</code> | A hex color to which the toolbar color is set. | 1.0.0 |
| **`presentationStyle`** | <code>'fullscreen' \| 'popover'</code> | iOS only: The presentation style of the browser. Defaults to fullscreen. Ignored on other platforms. | 1.0.0 |
| **`width`** | <code>number</code> | iOS only: The width the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 |
| **`height`** | <code>number</code> | iOS only: The height the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 |
| Prop | Type | Description | Since |
| ----------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| **`url`** | <code>string</code> | The URL to which the browser is opened. | 1.0.0 |
| **`windowName`** | <code>string</code> | Web only: Optional target for browser open. Follows the `target` property for window.open. Defaults to _blank. Ignored on other platforms. | 1.0.0 |
| **`toolbarColor`** | <code>string</code> | A hex color to which the toolbar color is set. | 1.0.0 |
| **`presentationStyle`** | <code>'fullscreen' \| 'popover'</code> | iOS only: The presentation style of the browser. Defaults to fullscreen. Ignored on other platforms. | 1.0.0 |
| **`width`** | <code>number</code> | iOS only: The width the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 |
| **`height`** | <code>number</code> | iOS only: The height the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 |
| **`entersReaderIfAvailable`** | <code>boolean</code> | iOS only: Whether to automatically enter Reader mode if available for the url Ignored on other platforms. | 4.0.0 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| **`entersReaderIfAvailable`** | <code>boolean</code> | iOS only: Whether to automatically enter Reader mode if available for the url Ignored on other platforms. | 4.0.0 |
| **`entersReaderIfAvailable`** | <code>boolean</code> | iOS only: Whether to automatically enter Reader mode if available for the url. Ignored on other platforms. | 4.0.0 |



#### PluginListenerHandle
Expand Down
7 changes: 5 additions & 2 deletions browser/ios/Sources/BrowserPlugin/Browser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import SafariServices
return safariViewController
}

@objc public func prepare(for url: URL, withTint tint: UIColor? = nil, modalPresentation style: UIModalPresentationStyle = .fullScreen) -> Bool {
@objc public func prepare(for url: URL, withTint tint: UIColor? = nil, modalPresentation style: UIModalPresentationStyle = .fullScreen, entersReaderIfAvailable: Bool = false) -> Bool {
if safariViewController == nil, let scheme = url.scheme?.lowercased(), ["http", "https"].contains(scheme) {
let safariVC = SFSafariViewController(url: url)
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = entersReaderIfAvailable

let safariVC = SFSafariViewController(url: url, configuration: config)
safariVC.delegate = self
if let color = tint {
safariVC.preferredBarTintColor = color
Expand Down
3 changes: 2 additions & 1 deletion browser/ios/Sources/BrowserPlugin/BrowserPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public class CAPBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
color = UIColor.capacitor.color(fromHex: toolbarColor)
}
let style = self.presentationStyle(for: call.getString("presentationStyle"))
let entersReaderIfAvailable = call.getBool("entersReaderIfAvailable") ?? false
// prepare for display
guard implementation.prepare(for: url, withTint: color, modalPresentation: style), let viewController = implementation.viewController else {
guard implementation.prepare(for: url, withTint: color, modalPresentation: style, entersReaderIfAvailable: entersReaderIfAvailable), let viewController = implementation.viewController else {
call.reject("Unable to display URL")
return
}
Expand Down
9 changes: 9 additions & 0 deletions browser/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ export interface OpenOptions {
* @since 4.0.0
*/
height?: number;

/**
* iOS only: Whether to automatically enter Reader mode if available for the url
*
* Ignored on other platforms.
*
* @since 5.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @since 5.0.0
* @since 8.x.y or whatever version is correct

*/
entersReaderIfAvailable?: boolean;
}

/**
Expand Down