Atom Unity

by ironSource
+

ironSource.atom SDK for Unity

( Updated 2 hours ago )

ironSource.atom SDK for Unity 3D - Beta Version

License Docs Build status Coverage Status

atom-unity is the official ironSource.atom SDK for the Unity 3D engine.

Installation

Using the IronSource API to send events

Example of sending an event in C#:

public class ButtonEvent : MonoBehaviour {
    private ironsource.IronSourceAtom api_ = null;

    void Start() {
        api_ = new ironsource.IronSourceAtom(gameObject);  
        // enabling print logs
        api_.EnableDebug(true);   
        api_.SetAuth("<YOUR_AUTH_KEY>");
    }

    // send single event
    public void OnPostClick(){
        // delegate callback type
        Action<ironsource.Response> callback = delegate(ironsource.Response response) {
            Debug.Log("from callback: status = " + response.status); 
        };

        api_.PutEvent("<YOUR_STREAM_NAME>", "{\"name\": \"iron\"}", 
                      ironsource.HttpMethod.POST, callback);
    }

    // antoher way of using api callback
    public static void ApiCallback(ironsource.Response response) {
        Debug.Log("from callback: status = " + response.status); 
    }

    // send list of events
    public void OnPostBulkClick() {
        List<string> events = new List<string>(); 
        events.Add("{\"name\": \"iron 1\"}");
        events.Add("{\"name\": \"iron 2\"}");
        events.Add("{\"name\": \"iron 3\"}");

        api_.PutEvents("<YOUR_STREAM_NAME>", events, ButtonEvent.ApiCallback);
    }
}

Example of sending an event in JavaScript:

private var api_ : ironsource.IronSourceAtom;

function Start() {
    api_ = new ironsource.IronSourceAtom(gameObject);  
    // enabling print logs
    api_.EnableDebug(true);        
    api_.SetAuth("<YOUR_AUTH_KEY>");
}

function ApiCallback(response : ironsource.Response) {
     Debug.Log("from callback: status = " + response.status);     
}

// send single event
function OnPostClick(){
    api_.PutEvent("<YOUR_STREAM_NAME>", "{\"event_name\": \"test post\"}", 
                  ironsource.HttpMethod.POST, ApiCallback);
}

//send list of events
function OnPostBulkClick() {
    var events :List.<String> = new List.<String>();
    events.Add("{\"name\": \"iron 1\"}");
    events.Add("{\"name\": \"iron 2\"}");
    events.Add("{\"name\": \"iron 3\"}");

    api_.PutEvents("<YOUR_STREAM_NAME>", events, ApiCallback);
}

Example

alt text

License

MIT