【问题标题】:How to connect Phantom wallet to a Flutter app using deep links?如何使用深度链接将 Phantom 钱包连接到 Flutter 应用程序?
【发布时间】:2022-08-22 13:55:16
【问题描述】:

我正在制作一个颤动的移动应用程序,我想使用连接深层链接将用户连接到 Phantom 钱包,然后将redirect_link 设置为应用程序的 Firebase 动态链接,但是我没有收到来自幻钱包作为查询参数。任何帮助将不胜感激!谢谢。

    标签: flutter dart firebase-dynamic-links phantom-wallet


    【解决方案1】:

    安装uni_linksurl_luncher包装

    将此意图添加到 androidManifest

      <intent-filter android:autoVerify="true">
        <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://YOUR_HOST -->
        <data
          android:scheme="https"
          android:host="[YOUR_HOST]" />
      </intent-filter>
    

    然后创建查询参数,如

     Map<String, dynamic> queryParameters = {
      "dapp_encryption_public_key":
          base58.encode(Uint8List.fromList(keypair.publicKey)),
      "cluster": "devnet",
      "app_url": "https://google.com",
      "redirect_link":
          "app://flutterdapp?handleQuery=onConnect}",
    };
    

    然后是午餐网址

    final url =Uri(
      scheme: "https",
      host: "phantom.app",
      path: "/ul/v1/onConnect",
      queryParameters: queryParameters,
    );
    
     launchUrl(
      url,
      mode: LaunchMode.externalNonBrowserApplication,
     );
    

    并从幻像接收数据

    StreamSubscription _sub;
    
     Future<void> initUniLinks() async {
     // ... check initialLink
    
    // Attach a listener to the stream
    _sub = linkStream.listen((String? link) {
      // Parse the link and warn the user, if it is not correct
    }, onError: (err) {
      // Handle exception by warning the user their action did not succeed
    });
    
    // NOTE: Don't forget to call _sub.cancel() in dispose()
     }
    
     // ...
    

    希望能帮到你

    【讨论】:

      猜你喜欢
      • 2021-12-15
      • 1970-01-01
      • 2020-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      • 2020-03-19
      • 1970-01-01
      相关资源
      最近更新 更多