This is the documentation for the OnLogin() method, which is used to connect and log in to the wallet using the Phantasma Link SDK.
Method Description
The OnLogin() method is responsible for connecting and logging in to the wallet. It checks if the Phantasma Link Client is ready and not logged in, then proceeds to initiate the login process. If successful, it triggers the OnLoginEvent with a success message; otherwise, it provides an appropriate error message.
Method Usage
/// <summary>/// Method used to connect to the wallet./// </summary>publicvoidOnLogin(){ // Check if the Phantasma Link Client is readyif (PhantasmaLinkClient.Instance.Ready) { // Check if the user is not already logged inif (!PhantasmaLinkClient.Instance.IsLogged) // Attempt to log inPhantasmaLinkClient.Instance.Login((result, msg) => { // If the login is successfulif (result) { // Trigger the OnLoginEvent with a success messageOnLoginEvent?.Invoke("Logged In.",false);Debug.LogWarning("Phantasma Link authorization logged."); }else { // Trigger the OnLoginEvent with an error messageOnLoginEvent?.Invoke("Phantasma Link authorization failed.",true);Debug.LogWarning("Phantasma Link authorization failed."); } });else // If the user is already logged in, trigger the OnLoginEvent with a success messageOnLoginEvent?.Invoke("Logged In.",false); }else { // If the Phantasma Link Client is not ready, display a warning and trigger the OnLoginEvent with an error messageDebug.LogWarning("Phantasma Link connection is not ready.");OnLoginEvent?.Invoke("Phantasma Link connection is not ready.",true);PhantasmaLinkClient.Instance.Enable(); }}