打开电子邮件应用程序网址

Dmi*_*kov 12 android android-intent ios web ios-universal-links

我想添加链接到我的网站“检查您的电子邮件”。如果用户使用 mob 版本链接,则应在浏览器中打开邮件应用程序或电子邮件服务 URL(如果应用程序不存在)。例如用户有 test@gmail.com。如果用户没有 Gmail 应用程序,链接应在浏览器中打开 gmail 应用程序或https://mail.google.com。也许最好启动用户首选的邮件应用程序而不是 gmail。

安卓

我发现https://developer.chrome.com/multidevice/android/intents带有意图链接 intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http %3A%2F%2Fzxing.org;end

它工作正常,但我无法理解如何使用https://play.google.com/store/apps/details?id=com.google.android.gm&hl=ru或任何其他应用程序做同样的事情

我还发现https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND打开邮件应用程序但 intent://send#Intent;action=android.intent.action.SEND;end 不起作用

任何人都可以给我打开 Gmail 应用程序或默认邮件应用程序的工作网址吗?

操作系统

通用链接https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12

互联网上有很多关于如何将您的网站与您的应用程序链接的文章。但是如何从我的网站启动另一个应用程序?

use*_*104 6

一种方法是在您的网站中添加一个链接,例如

<a href="mailto:user@domain.com?Subject=Hello%20User">Inbox me!</a>
Run Code Online (Sandbox Code Playgroud)

如果您的 Android 手机上没有安装任何邮件应用程序,这将不起作用。因此,您必须安装一个可以侦听此邮件事件/意图的应用程序,例如 GMail。如果安装了两个或多个可以处理此事件/意图的应用程序,Android 将显示一个应用程序列表,询问您使用哪个应用程序打开链接。

您要做的下一件事是将您自己的 Android 应用程序列为可以处理邮件事件/意图的应用程序之一。这是接收意图的用武之地。在您的 中Manifest.xml,声明您的活动如下:

<activity android:name="EmailHandlerActivity">
    <intent-filter>
        <action android:name="android.intent.action.SENDTO" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="mailto" />
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

参考:https : //developer.android.com/guide/components/intents-filters.html

更新:

这是从网页打开 android 应用程序的另一种方法。但要使其正常工作,您需要具体了解邮件应用程序的收件箱活动是如何在Manifest.xml. 如果活动声明如下:

<activity android:name="InboxActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="my_scheme" android:host="my_host" />
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

您可以将您的网址写为

<a href="intent://my_host#Intent;scheme=my_scheme;action=android.intent.action.VIEW;end">
    Go to Mail!
</a>
Run Code Online (Sandbox Code Playgroud)

  • 谢谢。我希望有一些通用的 mail-app:// 链接来打开默认邮件应用程序收件箱) (2认同)