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 463a894186e01d8cf2b845371feb1d1d1667fe64..0eb6d4919567d5f8830e9b025a6c04e67153a71a 100644 --- a/packages/url_launcher/url_launcher_ohos/example/lib/main.dart +++ b/packages/url_launcher/url_launcher_ohos/example/lib/main.dart @@ -117,6 +117,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}'); @@ -251,6 +267,13 @@ class _MyHomePageState extends State { if (_launchAppGalleryLog?.isNotEmpty ?? false) Text(_launchAppGalleryLog!), const Padding(padding: EdgeInsets.all(16.0)), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchEmail('mailto:admin@exmaple.com'); + }), + child: const Text('Launch in email'), + ), + const Padding(padding: EdgeInsets.all(16.0)), FutureBuilder(future: _launched, builder: _launchStatus), ], ), @@ -258,4 +281,4 @@ class _MyHomePageState extends State { ), ); } -} \ No newline at end of file +} 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 023e57a7bf1fb6fc0e52fdaaa7b44ca88c160e1f..dd7545910fb07a15cecb919308c625f1d0356903 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 @@ -222,8 +222,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)