Android initial setup

At a glance: The initial app setup enables the marketer to create links that send existing app users directly into the app. The initial setup is also a prerequisite for deep linking and deferred deep linking.

应用程序打开方法

There are two app opening methods that can be implemented to cover your entire user base. The method used depends on the mobile platform version.

以下各节将详细介绍这两种实现方法和说明。

方法描述Android版本程序
Android App Links在默认行为中直接打开移动应用程序。Android V6+
  1. 生成SHA256指纹识别。
  2. 在主要行为中添加意图过滤器。
URI 方案根据URI方案中指定的行为路径直接打开应用程序。Android所有版本
  1. 与营销人员共同决定URI方案。
  2. 在主要行为中添加意图过滤器。
  3. 测试

Android应用程序链接的步骤

Android App Links work with Android V6 and above. Learn more.

Generating a SHA256 fingerprint while in development

  1. Locate your app's keystore.
    If the app is in still in development, locate the debug.keystore
    • 对于Windows用户: C:\Users\USERNAME\.android\debug.keystore
    • 对于Linux或Mac OS用户: ~/.android/debug.keystore
  2. 打开命令行并导航到密钥库文件所在的文件夹。
  3. 运行命令:
// keytool -list -v -keystore <<KEY_STORE_FILE>>
// For example, the default keystore file 
keytool -list -v -keystore ~/.android/debug.keystore

🚧

debug.keystore的密码通常为“android” 。

输出应如下所示:

Alias name: test
Creation date: Sep 27, 2017
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=myname
Issuer: CN=myname
Serial number: 365ead6d
Valid from: Wed Sep 27 17:53:32 IDT 2017 until: Sun Sep 21 17:53:32 IDT 2042
Certificate fingerprints:
MD5: DB:71:C3:FC:1A:42:ED:06:AC:45:2B:6D:23:F9:F1:24
SHA1: AE:4F:5F:24:AC:F9:49:07:8D:56:54:F0:33:56:48:F7:FE:3C:E1:60
SHA256: A9:EA:2F:A7:F1:12:AC:02:31:C3:7A:90:7C:CA:4B:CF:C3:21:6E:A7:F0:0D:60:64:4F:4B:5B:2A:D3:E1:86:C9
Signature algorithm name: SHA256withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
  KeyIdentifier [
   0000: 34 58 91 8C 02 7F 1A 0F  0D 3B 9F 65 66 D8 E8 65 
   0010: 74 42 2D 44                    
 ]
]
  1. 将SHA256发回给营销人员。

Generating a SHA256 fingerprint while in production

The SHA256 fingerprint is generated in

  1. In Google Play console Find the public SHA256 fingerprint in Setup -> App signing (see image below)

Google Play SHA256 cert!

  1. 将SHA256发回给营销人员。

Adding App Link intent-filter to main activity

  1. Get the auto-generated intent-filter code from the marketer. The intent-filter code is used in the AndroidManifest.XML.
  2. Open the app's AndroidManifest.xml file.
  3. 将意图过滤器添加到主要行为
    如果主要行为中已经有Android应用链接意图过滤器,请覆盖它。

举例

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data
        android:host="onelink-basic-app.onelink.me"
        android:scheme="https" />
</intent-filter>

ℹ️

When android:autoVerify="true" is present on any of your intent filters, installing your app on devices with Android 6 and higher causes the system to attempt to verify all hosts associated with the URLs in any of your app's intent filters.
For each unique host name found in the above intent filters, Android queries the corresponding websites for the Digital Asset Links file at https://hostname/.well-known/assetlinks.json. Once the redirection logic for existing app users is added to the OneLink template configuration, AppsFlyer creates and hosts this path for you.
Learn more

Github链接:XML

  1. 告诉营销人员应用链接配置已完成。
    当营销人员测试链接时,它应该将用户引导到应用程序的主页。

URI方案的步骤

URI方案是将用户直接引导到移动应用程序的URL。

When an app user enters a URI scheme in a browser address bar, or clicks on a link based on a URI scheme, the app launches, and the user is deep linked.

每当应用链接无法打开应用程序时,URI方案可用作打开应用程序的后备方案。

Deciding on a URI scheme

决定URI方案:

  1. Contact the marketer.

  2. 选择URI方案。例如: yourappname://

    ℹ️

    • 使用对您的应用和品牌尽可能独特的URI方案,以避免与生态系统中的其他应用同时发生重复。与其他应用程序出现重叠是URI方案协议本质上的固有问题。
    • URI方案不应以httphttps开头。
    • URI方案应该在Android和iOS上进行类似的定义。
  3. Send the URI scheme to the marketer. For example: afshopapp://mainactivity

Adding URI scheme intent-filter to the main activity

在主要行为中添加意图过滤器:

  1. Open the app's AndroidManifest.xml file.
  2. Add the following intent-filter to the main activity.
    In the data section, replace host and scheme with the URI scheme you chose. In the intent-filter code below, host="mainactivity" and scheme="afshopapp", matching the URI scheme afshopapp://mainactivity.
    If there already is an intent-filter for the URI scheme in the main activity, overwrite it.
<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="mainactivity"
        android:scheme="afshopapp" />
</intent-filter>

⇲ Github链接:XML

  1. 将URI方案提供给营销人员。

Testing URI schemes

先决条件

An Android device with the app installed. Make sure it is the app source and version where you made changes and implemented App Links and/or a URI scheme.

测试URI方案

  1. 联系营销人员并获取他们创建的自定义链接。
  2. 将营销人员给您的短URL或长URL发送到您的手机上。您可以:
    • 使用手机摄像头或二维码扫描仪应用程序扫描二维码。
    • 通过电子邮件或WhatsApp自己发送链接,然后在手机上打开它。
  3. 点击移动设备上的链接。
    应用程序应该会打开它的主屏幕。