摘要 我正在创建Xamarin表单应用程序的节点js后端,并正在使用Firebase数据库存储数据。目前,我可以使用node js将字符串保存到Firebase数据库中,也可以使用c#直接从客户端代码中保存信息,但是为了更加安全,我决定在node js上运行firebase代码。并且不确定如何将Xamarin表单代码安全地连接到节点js。 (使用加密货币)。我下面有当前的节点js代码。
var admin = require('firebase-admin');
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: 'https://myfirebase.firebaseio.com/'
});
let db = admin.firestore();
let docRef = db.collection('users').doc('alovelace');
let setAda = docRef.set({
first: 'Ada',
last: 'Lovelace',
born: 1815
});
所以我的问题是我如何让我的Xamarin表单客户端代码发送字符串并使用此代码保存它们。将来,我将使用访问令牌,但到目前为止尚未使用。
我当前的c#代码没有数据库附件,但是我还是要添加(注册页面,并使用firebase身份验证)
namespace Kula
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
// set variables
string email;
string password;
Entry RinputEmail;
Entry RinputPassword;
public MainPage()
{
InitializeComponent();
// reference mainpage.xamal
RinputEmail = this.FindByName<Entry>("Remail");
RinputPassword = this.FindByName<Entry>("Rpassword");
}
async private void GTLogin_Clicked(object sender, EventArgs e)
{
//navigate to Login page
await Navigation.PushAsync (new Login());
}
private void registerUser_Clicked(object sender, EventArgs e)
{
//set users input to strings
email = (RinputEmail.Text).ToString();
password = (RinputPassword.Text).ToString();
}
}
}