Skip to content

datonomy/datonomyKit-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DatonomySDK Documentation

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.

Initial Setup

  1. Ensure that the IOSNativeBridgeManager (this is an exemple file) is attached to a GameObject in your scene named IOSBridgeManager.
  2. 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.
  3. All the functions have their own callback:

Getting Started

After adding the IOSNativeBridge class to your project, it's essential to understand how to reference and use it.

1. Namespace

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.

Using a 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();

Using the Full Name

Datonomy.DatonomySDK.IOSNativeBridge bridge = new Datonomy.DatonomySDK.IOSNativeBridge();

Sample Code for Initial Setup:

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
    }
    ...

Available Methods

InitializeSDK

Initializes the SDK with a specific API key.

Parameters:

apiKey (string): The API key for authentication. Usage Example:

InitializeSDK("YourAPIKeyHere");

RequestLTVScore

Requests the user's LTV (Lifetime Value) score. The response is natively processed by the SDK.

Usage Example:

GetLTVScore();

ReportEvent

Reports a specific event to the platform.

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);

Callbacks Documentation for DatonomySDK

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.

1. Initialization Completion Handler

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.

Signature:

[AOT.MonoPInvokeCallback(typeof(Action<int>))]
private static void completionHandler(int result)

Behavior:

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.

  1. 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)

Behavior:

Logs the received LTV score.

  1. 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)

Behavior:

Logs the state of the event reporting process.

Additional Considerations

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published