配置Android应用程序的Scheme:
在Flutter项目的android/app/src/main/AndroidManifest.xml文件中,添加如下代码片段到标签内部:
<activity
android:name="com.your.package.MainActivity"
android:launchMode="singleTask">
<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="your-scheme"
android:host="your-host" />
</intent-filter>
</activity>
1.将com.your.package.MainActivity替换为你的应用程序的主Activity类名。将your-scheme和your-host替换为你想要配置的Scheme和Host。
2.如果你的应用程序需要处理其他参数,可以在标签中添加额外的Intent Filter数据行,例如:
<data
android:scheme="your-scheme"
android:host="your-host"
android:pathPattern="/some-path/*" />
3.保存并重新构建你的Android应用程序。
配置iOS应用程序的Scheme:
1.在Flutter项目的ios/Runner/Info.plist文件中,找到或创建一个CFBundleURLTypes键的数组项,并添加一个子字典条目:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>your-scheme</string>
</array>
</dict>
</array>
2.如果你的应用程序需要处理其他参数,可以在子字典中添加额外的String项,例如:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>your-scheme</string>
</array>
<key>CFBundleURLAdditionalSchemes</key>
<array>
<string>other-scheme</string>
</array>
</dict>
</array>
3.保存并重新构建你的iOS应用程序。