[英]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.