The DatonomySDK
provides seamless and rapid integration with native iOS Datonomy services for Unity. Below, you'll find a brief description of how to set up and use the main features of the SDK.
- Ensure that the
IOSNativeBridgeManager
(this is an exemple file) is attached to aGameObject
in your scene namedIOSBridgeManager
. - In the
Start
method of your script, the SDK will automatically initialize with the provided API key. If you need to use one provided by Datonomy, replace this string with the desired value. - All the functions have their own callback:
After adding the IOSNativeBridge
class to your project, it's essential to understand how to reference and use it.
The class is wrapped inside the Datonomy.DatonomySDK
namespace. This means that to access the class, you'll need to either use the full name or add a using directive.
At the top of your C# script, add:
using Datonomy.DatonomySDK;
And then you can reference the class like so:
IOSNativeBridge bridge = new IOSNativeBridge();
Datonomy.DatonomySDK.IOSNativeBridge bridge = new Datonomy.DatonomySDK.IOSNativeBridge();
using UnityEngine;
using Datonomy.DatonomySDK;
public class IOSNativeBridgeManager : MonoBehaviour
{
private IIOSNativeBridge _bridge;
private void Awake()
{
#if UNITY_IOS
Datonomy.DatonomySDK.IOSNativeBridge _bridge = new Datonomy.DatonomySDK.IOSNativeBridge();
#else
Debug.LogWarning("Not running on iOS, the bridge won't be instantiated.");
#endif
}
void Start()
{
#if UNITY_IOS
InitializeSDK("your api key");
#else
Debug.LogWarning("Not running on iOS, SDK initialization skipped.");
#endif
}
...
Initializes the SDK with a specific API key.
Parameters:
apiKey (string): The API key for authentication. Usage Example:
InitializeSDK("YourAPIKeyHere");
Usage Example:
GetLTVScore();
Parameters:
eventName (Object): The name of the event you wish to report. Usage Example:
AdEvent adEventStatic = new AdEvent
{
type = 0,
impression = new Impression
{
TypeAdsString = AdsType.banner, // Use TypeAdsString em vez de typeAds
Revenue = 5.5,
NetworkName = "SampleNetwork",
Currency = "BRL"
}
};
string adEventBase64 = adEventStatic.ToBase64();
Event(EventObject);
In the DatonomySDK
, several callbacks are used to handle responses and events natively. This documentation provides insights into these callbacks, offering a clear understanding of their functionalities and use cases.
The completionHandler
is primarily invoked once the SDK initialization is finished. It's used to handle the result of the initialization and to manage events that follow.
[AOT.MonoPInvokeCallback(typeof(Action<int>))]
private static void completionHandler(int result)
Creates an AdEvent instance with defined attributes. Converts the AdEvent to a Base64 string and logs it. Converts the Base64 string back to its JSON format and logs the JSON. Logs the state of SDK initialization. Makes calls to fetch the LTV score and reports an event. Usage Notes: Ensure you're using the TypeAdsString instead of typeAds when setting the impression type.
- LTV Score Completion Handler This callback, completionHandlerLTVScore, is triggered to handle the response after requesting the LTV (Lifetime Value) score for a user.
Signature:
Copy code
[AOT.MonoPInvokeCallback(typeof(Action<double>))]
private static void completionHandlerLTVScore(double score)
Logs the received LTV score.
- Event Completion Handler The completionHandlerEvent handles the result after reporting a specific event to the platform.
Signature:
Copy code
[AOT.MonoPInvokeCallback(typeof(Action<int>))]
private static void completionHandlerEvent(int result)
Logs the state of the event reporting process.
Ensure that all dependencies and native libraries required for the DatonomySDK are correctly imported and set up in your Unity project. To make sure the SDK operates correctly, refrain from invoking its methods before it has been initialized. Keep the SDK updated to the latest versions to ensure optimal compatibility and security. We hope this documentation aids you in effectively integrating and utilizing the DatonomySDK. Should you have further questions, please reach out to our support team.