簡體   English   中英

flutter 深度鏈接在真實設備上不起作用

[英]flutter deep linking don't work on a real device

我正在嘗試向我的應用添加深層鏈接,我正在使用uni_links

我按照頁面上的說明進行操作,在 android 模擬器上一切正常 - 我通過深層鏈接打開應用程序,快照有數據並返回 urlResponse,但在真實設備上,當我通過深層鏈接打開應用程序時,快照沒有任何數據,返回主頁。

這是我的代碼:

    class MyApp extends StatelessWidget {
          @override
          Widget build(BuildContext context) {
            return MaterialApp(
              debugShowCheckedModeBanner: false,
              theme: ThemeData(
                primaryColor: Colors.white,
                visualDensity: VisualDensity.adaptivePlatformDensity,
              ),
              home: StreamBuilder(
                stream: getLinksStream(),
                builder: (context, snapshot) {
                  if (snapshot.hasData) {
                    // our app started by configured links
                    Uri uri = Uri.parse(snapshot.data);
                    List<MapEntry<String, List<String>>> list =
                        uri.queryParametersAll.entries.toList();
                    return urlResponse(uri, list);
                  } else {
                    // our app started regularly
                    return HomePage();
                  }
                },
              ),
            );
          }

和我的 AndroidManifest.xml:

    <!-- 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 YOUR_SCHEME://YOUR_HOST -->
          <data
            android:scheme="http"
            android:host="example.com"
            android:pathPrefix="/myApp"/>
        </intent-filter>

誰能幫我理解為什么它可以在模擬器上運行而不是在真實設備上運行?

在 package 頁面中,作者說“通常你會檢查getInitialLink並監聽變化。” 當您在 android 模擬器上嘗試時,您可能在后台使用了該應用程序,但是當您使用真實設備嘗試時,該應用程序未打開。 試用作者獲得的示例代碼,如果問題仍然存在,請在他的 github 頁面中報告該問題。

這些鏈接的問題在於,即使您沒有任何 dart 代碼,只要使用intent-filter ,應用程序就會打開。 因此,當應用程序啟動時可能會有些混亂,但未顯示數據。 我會嘗試getInitialLink

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM