[英]Plaid Integration With Xamarin forms
因为我要开始一个新的 Xamarin 项目,我想将 Plaid 客户端与该项目集成。 客户需要使用 Xamarin 表单(iOS 和 Android)构建该项目。 能否请您给我发送一些教程或文档,以参考在 Xamarin Forms(iOS 和 Android)中集成 Plaid。
是的,我得到了答案..
为此,我们需要在 iOS 项目中的 info.plist 和 assemblyInfo.cs 类中进行更改。 以下是您需要进行的更改。
@对于 iOS,您需要在 info.plist 文件的 NSAppTransportSecurity 字典中将 NSAllowsArbitaryLoads 键添加到 YES。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
@ UIWebview 从 iOS 13 中被弃用。因此,您需要使用 wkwebview 而不是 webview。 将以下代码添加到应用程序的 iOS 平台项目中的 AssemblyInfo.cs 文件中
// Opt-in to using WkWebView instead of UIWebView.
[assembly: ExportRenderer(typeof(WebView), typeof(Xamarin.Forms.Platform.iOS.WkWebViewRenderer))]
并在您的页面 /UI 中添加 web 视图并将其命名为“webView”。 并在后面的代码中添加以下代码。
using System;
using System.Diagnostics;
using System.Web;
using Foundation;
using Xamarin.Forms;
namespace PlaidLinkXamarinForms
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
var publickey = "YOUR_PUBLIC_KEY";
var env = "Sandbox"; //development, production
var product = "auth"; //transactions, auth, identity, income, assets, investments, liabilities
var clientName = "PlaidLinkXamarinForms"
var url = "https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&key=" + publickey + "&env=" + env + "&product=" + product + "&selectAccount=true&clientName=" + clientName + "&isMobile=true";
webView.Source = url;
webView.Navigating += async (sender, e) =>
{
if (e.Url.ToLower().Contains("plaidlink:"))
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
var linkScheme = "plaidlink";
var scheme = new Uri(e.Url);
var param = HttpUtility.ParseQueryString(e.Url);
var actionScheme = scheme.Scheme;
var actionType = scheme.Host;
if(actionScheme == linkScheme)
{
switch (actionType)
{
case "connected":
Debug.WriteLine("Successfully Connected");
break;
case "exit":
Debug.WriteLine("Exit");
break;
case "event":
Debug.WriteLine($"Event name: {param["event_name"]}");
break;
default:
Debug.WriteLine($"Link action detected: {actionType}");
break;
}
}
};
}
}
}
在执行此操作之前,您应该在 Plaid 网站中配置您的帐户。 在那里你会得到一些你必须在上面的代码中添加的键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.