मैं Xamarin.Forms.ContentPage
वर्ग संरचना निम्नलिखित हैलिखें उपकरण प्लेटफ़ॉर्म Xamarin.Forms में विशिष्ट कोड
public class MyPage : ContentPage
{
public MyPage()
{
//do work to initialize MyPage
}
public void LogIn(object sender, EventArgs eventArgs)
{
bool isAuthenticated = false;
string accessToken = string.Empty;
//do work to use authentication API to validate users
if(isAuthenticated)
{
//I would to write device specific code to write to the access token to the device
//Example of saving the access token to iOS device
NSUserDefaults.StandardUserDefaults.SetString(accessToken, "AccessToken");
//Example of saving the access token to Android device
var prefs = Application.Context.GetSharedPreferences("MySharedPrefs", FileCreationMode.Private);
var prefsEditor = prefs.Edit();
prefEditor.PutString("AccessToken", accessToken);
prefEditor.Commit();
}
}
}
मैं MyPage
LogIn
विधि में मंच विशिष्ट कोड लिखने के लिए करने वाले डिवाइस के ओएस आधारित पहुँच टोकन को बचाने के लिए चाहते हैं वे मेरे आवेदन का उपयोग कर रहे हैं।
जब उपयोगकर्ता अपने डिवाइस पर अपने एप्लिकेशन का उपयोग करता है तो मैं केवल डिवाइस विशिष्ट कोड कैसे चला सकता हूं?
'ऐप 'क्लास कोड स्निपेट पर, मुझे कोड की कोशिश करते समय" विधि का रिटर्न टाइप होना चाहिए "प्राप्त हो रहा है। क्या इसका रिटर्न प्रकार 'शून्य' होना चाहिए? –
इनिट विधि में शायद 'शून्य' रिटर्न प्रकार होना चाहिए। – valdetero
धन्यवाद, मैंने 'ऐप' कोड नमूना संपादित किया है। –