【问题标题】:email link that opens mobile app is installed安装打开移动应用程序的电子邮件链接
【发布时间】:2015-08-21 16:04:40
【问题描述】:

我需要一种在电子邮件中包含链接的方法,该链接可以打开移动应用程序或将用户重定向到网站,具体取决于是否安装了移动应用程序。我需要一个适用于 Android 和 IOS 的解决方案,是否有一套关于如何实现这一点的实践?

谢谢!

【问题讨论】:

    标签: android ios mobile-application


    【解决方案1】:

    我认为你需要一个组合的答案。

    对于 iOS,您可以将 http:// 替换为 itms:// 或 itms-apps:// 以避免重定向。

    How to link to apps on the app store

    对于 Android,我认为您需要查看 Mainfest 文件的 <intent-filter> 元素。具体来说,请查看<data> 子元素的文档。

    Make a link in the Android browser start up my app?

    【讨论】:

      【解决方案2】:

      在 Android 上,您需要通过 Intent Filter 来处理:

          <activity
              android:name="com.permutassep.IntentEvaluator"
              android:label="@string/app_name">
              <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:host="your/url"
                      android:scheme="http" />
                  <data
                      android:host="your/url"
                      android:scheme="https" />
      
              </intent-filter>
          </activity>
      

      你需要处理意图数据的类应该是这样的:

      public class IntentEvaluator extends BaseActivity {
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
      
              Intent intent = null;
      
              if(getIntent() != null && getIntent().getData() != null){
               // Do whatever you want with the Intent data.
      
              }
          }
      }
      

      取自我开发的应用程序:https://raw.githubusercontent.com/lalongooo/permutas-sep/master/app/src/main/java/com/permutassep/IntentEvaluator.java

      【讨论】:

        猜你喜欢
        • 2012-07-30
        • 2013-08-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-17
        • 1970-01-01
        • 2019-10-14
        相关资源
        最近更新 更多