// LeanStorage
using LeanCloud;
// LeanMessage (optional)
using LeanCloud.Realtime;
Initializing LeanStorage
Run the following code before using LeanStorage:
AVClient.Initialize("{{appid}}", "{{appkey}}");
Initializing LeanMessage
Run the following code before using LeanMessage:
const realtime = new AVRealtime("{{appid}}", "{{appkey}}");
Enabling Debug Logs
You can easily trace the problems in your project by turning debug logs on during the development phase. Once enabled, details of every request made by the SDK along with errors will be output to IDE, browser console, or your app's Dashboard > LeanEngine > App logs.
// Enable debug logs for LeanStorage
AVClient.HttpLog(Debug.Log);
// Enable debug logs for LeanMessage
AVRealtime.WebSocketLog(Debug.Log);
Make sure debug logs are turned off before your app is published. Failure to do so may lead to the exposure of sensitive data.
Verifying
First of all, make sure you are able to connect to LeanCloud server. You can test it by running the following command:
curl "https://{{domain}}/1.1/date"
If everything goes well, it will return the current date:
This guide is written for the latest version of our SDK. If you encounter any error, please first make sure you have the latest version installed.
401 Unauthorized
If you get a 401 error or see the following content in network logs:
{
"code": 401,
"error": "Unauthorized."
}
It means that the App ID or App Key might be incorrect or don't match. If you have multiple apps, you might have used the App ID of one app with the App Key of another one, which will lead to such error.
Client Cannot Access the Internet
Make sure you have granted enough permissions for your mobile app.
How to Install the .NET SDK
Installing SDK
Unity
Supports iOS, Android, UWP, Windows Desktop, and web games built with Unity.
Installing LeanStorage
Download the latest version of Unity Storage, unzip it, and import it into your Unity project.
Installing LeanMessage
Download the latest version of Unity Realtime, unzip it, and import it into your Unity project.
Breakdown
You will find the following dependencies after unzipping the files:
AssemblyLister.dll
LeanCloud.Core.dll
AVObject
andAVUser
.LeanCloud.Storage.dll
LeanCloud.Realtime.dll
.NET Framework
.NET Framework supports the .NET Framework 4.5+ runtime.
Install nuget in Visual Studio:
Initializing Your Project
To begin with, get your App ID and App Key from your app's Dashboard > Settings > App Keys.
Import basic modules:
Initializing LeanStorage
Run the following code before using LeanStorage:
Initializing LeanMessage
Run the following code before using LeanMessage:
Enabling Debug Logs
You can easily trace the problems in your project by turning debug logs on during the development phase. Once enabled, details of every request made by the SDK along with errors will be output to IDE, browser console, or your app's Dashboard > LeanEngine > App logs.
Make sure debug logs are turned off before your app is published. Failure to do so may lead to the exposure of sensitive data.
Verifying
First of all, make sure you are able to connect to LeanCloud server. You can test it by running the following command:
If everything goes well, it will return the current date:
Then add the following code into your project:
Save the file and run it.
Then go to your app's Dashboard > LeanStorage > Data >
TestObject
. If you see the following content, it means that you have correctly installed the SDK.See Debugging if you're not seeing the content.
Debugging
This guide is written for the latest version of our SDK. If you encounter any error, please first make sure you have the latest version installed.
401 Unauthorized
If you get a
401
error or see the following content in network logs:It means that the App ID or App Key might be incorrect or don't match. If you have multiple apps, you might have used the App ID of one app with the App Key of another one, which will lead to such error.
Client Cannot Access the Internet
Make sure you have granted enough permissions for your mobile app.