EccCapacitorBrowser 1.1.1

EccCapacitorBrowser 1.1.1

Fontos Soluções 维护。



@capacitor/browser

浏览器 API 提供了在应用内打开浏览器并订阅浏览器事件的 capability

在 iOS 上,这使用 SFSafariViewController 并且与领先的 OAuth 服务应用内浏览器要求兼容。

安装

npm install @ieadpe/ecc-capacitor-browser
npx cap sync

Android

变量

此插件将使用以下项目变量(在您的应用的 variables.gradle 文件中定义)

  • androidxBrowserVersion:androidx.browser:browser 的版本(默认:1.7.0

示例

import { Browser } from '@capacitor/browser';

const openCapacitorSite = async () => {
  await Browser.open({ url: 'http://capacitorjs.com/' });
};

API

open(...)

open(options: EccCapacitorBrowserOpenOptions) => Promise<void>

使用指定选项打开一个页面。

参数 类型
options EccCapacitorBrowserOpenOptions

自从 1.0.0


close()

close() => Promise<void>

Web 和 iOS:关闭打开的浏览器窗口。

在其他平台上无操作。

自从 1.0.0


addListener('ieadpeBrowserFinished', ...)

addListener(eventName: 'ieadpeBrowserFinished', listenerFunc: () => void) => Promise<PluginListenerHandle>

Android 和 iOS:监听浏览器完成事件。当浏览器被用户关闭时触发。

参数 类型
事件名 'ieadpeBrowserFinished'
listenerFunc () => void

返回: Promise<a href="#pluginlistenerhandle">PluginListenerHandle>

自从 1.0.0


addListener('ieadpeBrowserPageLoaded', ...)

addListener(eventName: 'ieadpeBrowserPageLoaded', listenerFunc: () => void) => Promise<PluginListenerHandle>

Android 和 iOS:监听页面加载事件。这仅在 open 方法传递的 URL 加载完成后触发。对于任何后续的页面加载都不会调用。

参数 类型
事件名 'ieadpeBrowserPageLoaded'
listenerFunc () => void

返回: Promise<a href="#pluginlistenerhandle">PluginListenerHandle>

自从 1.0.0


addListener('ieadpeBrowserLoggedIn', ...)

addListener(eventName: 'ieadpeBrowserLoggedIn', listenerFunc: (ieadpeDataReturn: EccCapacitorBrowserReturnOptions) => void) => Promise<PluginListenerHandle>

Android 和 iOS:监听 URL 加载。当来自服务器的 URL 从重定向登录成功触发

参数 类型
事件名 'ieadpeBrowserLoggedIn'
listenerFunc (ieadpeDataReturn: EccCapacitorBrowserReturnOptions) => void

返回: Promise<a href="#pluginlistenerhandle">PluginListenerHandle>

自从 1.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

移除此插件的所有原生监听器。

自从 1.0.0


接口

EccCapacitorBrowserOpenOptions

表示传递给 open 的选项。

属性 类型 描述 自从
url string 浏览器打开的 URL 1.0.0
windowName string Web 仅:浏览器打开的目标。遵循 window.open 的 target 属性。默认为 _blank。在其他平台上忽略。 1.0.0
toolbarColor string 设置工具栏颜色的十六进制颜色值。 1.0.0
presentationStyle 'fullscreen' | 'popover' iOS 仅:浏览器的呈现风格。默认为 fullscreen。在其他平台上忽略。 1.0.0
width number iOS 仅:使用 presentationStyle 'popover' 在 iPad 上使用时浏览器的宽度。在其他平台上忽略。 4.0.0
height number iOS 仅:使用 presentationStyle 'popover' 在 iPad 上使用时浏览器的宽度。在其他平台上忽略。 4.0.0

PluginListenerHandle

属性 类型
remove () => Promise<void>

EccCapacitorBrowserReturnOptions

表示传递给 open 的选项。

属性 类型 描述 自从
url string 浏览器返回的 URL。 1.0.0