From 23f79420bb506e081fd24b2324646d7351a6b6b7 Mon Sep 17 00:00:00 2001 From: "apang.men" Date: Fri, 24 Jan 2025 16:15:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=89=93=E5=BC=80=E9=82=AE=E7=AE=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: apang.men --- .../url_launcher_ohos/example/lib/main.dart | 23 +++++++++++++++++++ .../ets/components/plugin/UrlLauncher.ets | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/url_launcher/url_launcher_ohos/example/lib/main.dart b/packages/url_launcher/url_launcher_ohos/example/lib/main.dart index 9589c2c63..b3d589eec 100644 --- a/packages/url_launcher/url_launcher_ohos/example/lib/main.dart +++ b/packages/url_launcher/url_launcher_ohos/example/lib/main.dart @@ -116,6 +116,22 @@ class _MyHomePageState extends State { } } + Future _launchEmail(String url) async { + if (!await launcher.launch( + url, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: { + 'harmony_browser_page': 'pages/LaunchInAppPage' + }, + )) { + throw Exception('Could not launch $url'); + } + } + Widget _launchStatus(BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); @@ -215,6 +231,13 @@ class _MyHomePageState extends State { child: const Text('Launch in app + close after 5 seconds'), ), const Padding(padding: EdgeInsets.all(16.0)), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchEmail('mailto:admin@exmaple.com'); + }), + child: const Text('Launch in emial'), + ), + const Padding(padding: EdgeInsets.all(16.0)), FutureBuilder(future: _launched, builder: _launchStatus), ], ), diff --git a/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets b/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets index 2b9ee815d..6b1d26409 100644 --- a/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets +++ b/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets @@ -218,8 +218,8 @@ export class UrlLauncher implements UrlLauncherApi { launchMail(url: string): boolean { let mailAddress = this.parseUrl(url, UrlLauncher.LAUNCH_TYPE_MAILTO + ':'); let want: Want = { - abilityName: 'PhoneAbility', - bundleName: 'com.huawei.hmos.email', + action: 'ohos.want.action.sendToData', + uri: mailAddress } try { this.context.startAbility(want) -- Gitee From 9b5f3e1e9b9f77def37fbd36c3ca9a6aac5e6fc7 Mon Sep 17 00:00:00 2001 From: "apang.men" Date: Thu, 20 Feb 2025 10:04:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?email=E5=8D=95=E8=AF=8D=E7=BA=A0=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: apang.men --- packages/url_launcher/url_launcher_ohos/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/url_launcher/url_launcher_ohos/example/lib/main.dart b/packages/url_launcher/url_launcher_ohos/example/lib/main.dart index 2ab433465..0eb6d4919 100644 --- a/packages/url_launcher/url_launcher_ohos/example/lib/main.dart +++ b/packages/url_launcher/url_launcher_ohos/example/lib/main.dart @@ -271,7 +271,7 @@ class _MyHomePageState extends State { onPressed: () => setState(() { _launched = _launchEmail('mailto:admin@exmaple.com'); }), - child: const Text('Launch in emial'), + child: const Text('Launch in email'), ), const Padding(padding: EdgeInsets.all(16.0)), FutureBuilder(future: _launched, builder: _launchStatus), -- Gitee