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

iecba09b  于 2023-10-22  发布在  Flutter
关注(0)|答案(1)|浏览(145)

我得到了一个验证链接在我的雅虎邮件点击这个链接应该路由我到我的Flutter应用程序,但它去404页,并使用adb测试命令的应用程序被打开
我用的是applinks

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

pobjuy32

pobjuy321#

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

相关问题