首页 > 解决方案 > 如何将特定链接重定向到您的应用,类似于 whatsapp

问题描述

如何创建您的应用程序的链接?像WhatsApp。如果您单击此链接https://wa.me/546497546464 ,该链接会将您带到手机中的 WhatsApp 应用程序。喜欢如何创建一个链接,将用户带到应用程序中的特定屏幕? - -在颤抖中- -

标签: flutterhyperlink

解决方案


这就是所谓的深度链接

以下来自https://flutter.dev/docs/development/ui/navigation/deep-linking

在 Android 上启用深度链接

将元数据标签和意图过滤器添加到具有“.MainActivity”名称AndroidManifest.xml的标签内:<activity>

<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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:scheme="http" android:host="flutterbooksample.com" />
    <data android:scheme="https" />
</intent-filter>

在 iOS 上启用深度链接

Info.plist在 ios/Runner 目录中添加两个新密钥:

<key>FlutterDeepLinkingEnabled</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
    <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>flutterbooksample.com</string>
    <key>CFBundleURLSchemes</key>
    <array>
    <string>customscheme</string>
    </array>
    </dict>
</array>

推荐阅读