点击深层链接不会打开flutter应用程序并导航到页面404

问题描述 投票:0回答:2

我的雅虎邮件中有一个验证链接,单击此链接应该会将我转到我的 flutter 应用程序 但它转到第 404 页并使用 adb test 命令打开应用程序
我正在使用应用程序链接

class _MyAppState extends State<MyApp> {
  var loading=true.obs;
  final _appLinks = AppLinks();
  final profileController=Get.put(ProfileController());

  @override
  void initState() {
    profileController.initData();
    Timer(const Duration(seconds: 5), () {
      loading.value=false;
    });
    _appLinks.allUriLinkStream.listen((uri) {
      String? userId = uri.queryParameters['userid'];
      String? token = uri.queryParameters['token'];
      if(kDebugMode){
        print('User ID: $userId');
        print('Token: $token');
      }
      Get.offNamed("/verify_client",arguments: [userId,token]);
    });
    super.initState();
  }
}

And unilinks also 
void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await VerificationHandler.initUniLinks();
  runApp(const MyApp());
}
class VerificationHandler {
  static late StreamSubscription sub;
  static  initUniLinks() async {
    final initialLink = await getInitialLink();

    sub = uriLinkStream.listen((Uri? uri) {
     if(uri!=null){
       if(kDebugMode){
         print(initialLink);
         print(uri);
       }
       if (uri.host == 'mohamyninja.com' ||uri.host=='new.mohamyninja.com'){
         String? userId = uri.queryParameters['userid'];
         String? token = uri.queryParameters['token'];
         if(kDebugMode){
           print('User ID: $userId');
           print('Token: $token');
         }
         Get.offNamed("/verify_client",arguments: [userId,token]);
       }
     }
      // Use the uri and warn the user, if it is not correct
    }, onError: (err) {
      // Handle exception by warning the user their action did not succeed
    });
  }
}

清单文件配置
<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.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="https" android:host="mohamyninja.com" android:pathPrefix="/" />
    <data android:scheme="https" android:host="new.mohamyninja.com" android:pathPrefix="/" />
            <data android:scheme="http" />
</intent-filter>

这是验证链接 https://mohamyninja.com/userid=51_token=dcfde478bd46d67b5a4e1aada7b27188
flutter deep-linking applinks
2个回答
0
投票

您是否创建了 assetlinks.json 和 apple-app-site-association 文件并将它们存储在您的服务器中?


0
投票

我也有同样的问题,不知道有没有解决办法?谢谢。我有 assetlinks.json 和 apple-app-site-association 并且它可以在 IOS 中工作

© www.soinside.com 2019 - 2024. All rights reserved.