繁体   English   中英

如何使用深度链接将 Phantom 钱包连接到 Flutter 应用程序?

[英]How to connect Phantom wallet to a Flutter app using deep links?

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

安装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()
 }

 // ...

希望能帮到你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM