android 同时创建显示此错误的 Flutter 深度链接

rsaldnfx  于 2023-11-15  发布在  Android
关注(0)|答案(2)|浏览(145)

我已经在flutter app -> android -> src -> main -> androidmanifest.xml中添加了这段代码,但现在仍然可以工作

<!-- Intent filter for handling deep links -->
<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <!-- Accepts URIs that begin with "https://www.example.com/gizmos" -->
    <data
        android:scheme="https"
        android:host="www.example.com"
        android:pathPrefix="/gizmos" />
</intent-filter>

字符串
添加此后仍然不工作

vnjpjtjt

vnjpjtjt1#

确保Intent过滤器位于要处理深层链接的标签内。它应该嵌套在标签内,而不是AndroidManifest.xml中的任何位置。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package.name">
<application>
    <activity android:name=".MainActivity">
        <!-- ... other configurations ... -->

        <!-- Intent filter for handling deep links -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <!-- Accepts URIs that begin with "https://www.example.com/gizmos" -->
            <data
                android:scheme="https"
                android:host="www.example.com"
                android:pathPrefix="/gizmos" />
        </intent-filter>
    </activity>

    <!-- ... other activities ... -->
</application>

字符串

ffscu2ro

ffscu2ro2#

你必须首先将“uni_links”包添加到项目中:

import 'package:uni_links/uni_links.dart';
void main() {  
    runApp(MyApp());
}

class MyApp extends StatefulWidget {  
    @override  
    MyAppState createState() => MyAppState();
}

class _MyAppState extends State<MyApp> {  
    @override  
    void initState() {    
        super.initState();    
        initUniLinks();  
    } 

    void initUniLinks() async {    
        String initialLink = await getInitialLink();    
        // Handle the initial link, e.g., by navigating to a specific screen  
    }  

    @override  Widget build(BuildContext context) {    
    // Your app's build method  
    }
}

字符串

相关问题