Setup SDK
Unity Cross Platform SDK Integration Guide
Overview
This guide is for developers who want to monetize Windows/Android/IOS/Others Unity applications with PacketSDK.
It should be noted that due to the strict network permission policy of the browser, the SDK cannot run properly in web applications within the browser.
Integrating the PacketSDK into an application is the first step toward earning revenue. Once you've integrated the SDK, you will start seeing devices data and revenue in PacketSDK Dashboard in 24 hours.
This document will walk you through the steps needed to be taken inorder to properly integrate PacketSDK into your application.
Prerequisites
Step 1: Apply for appkey.
appkey is an important way to track your earnings, please ensure it is set correctly in the subsequent integration steps.
Step 2: Download Unity Cross Platform integration package.
Download the PacketSDK Unity-CrossPlatform integration package
packet_sdk_unity_crossplatform-1.0.*.zipand unzip it. Once you unzip the package, you can see the following contents: packet_sdk_unity_crossplatform-1.0.*.zip ├───PacketSDK.dll - Library required for unity integration. └───README.html
Unity Cross Platform Integration
Step 1: Copy the file required for integration to your Unity project.
Copy
PacketSDK.dllto the "Assets" directory of your project.
Step 2: Refer to the image below to add a "New script" component to a Unity object.

Step 3: Import the "PacketSDKAPI" namespace into the mono script which added in the previous step and call the relevant API.
Import all types within the "PacketSDKAPI" namespace in your code.
using PacketSDKAPI;Refer to the API documentation at the bottom of this guide and directly call the relevant API.
using System.Collections; using System.Collections.Generic; using UnityEngine; using PacketSDKAPI; public class NewBehaviourScript : MonoBehaviour { static void onPacketSDKCallBack(packet_status_t status) { Debug.Log("Packet SDK callback with status: " + PacketSDK.StatusToString(status)); } // Start is called before the first frame update void Start() { Debug.Log("MyScript started!"); PacketSDK.SetCallBack(onPacketSDKCallBack); packet_status_t status = PacketSDK.SetAppKey("appkey"); Debug.Log("SetAppkey: " + PacketSDK.StatusToString(status)); status = PacketSDK.Start(); Debug.Log("SDKStart: " + PacketSDK.StatusToString(status)); } // Update is called once per frame void Update() { } }
Step 4: Select the target platform and build it.
In order to obtain log information in the next step, you need to open the "Development Build" and "Autoconnect Profiler" options during the debugging phase.

Step 5: Verify if integration is successful.
After call
PacketSDK.Start()API, if you receivePACKET_SDK_SERVER_OBTAINEDPACKET_SDK_SERVER_CONNECTEDandPACKET_SDK_SERVER_CERTIFIEDin the callback function you set, it indicates that you have successfully integrated Packet SDK into your application.Once you've received
PACKET_SDK_SERVER_CERTIFIEDin the callback function, you will start seeing devices data and revenue in PacketSDK Dashboard in 24 hours.

API documentation
delegate void CallBackDelegate(packet_status_t status ) - Packet SDK callback function OverviewOverviewsignature.
static void SetCallBack(CallBackDelegate callBackFunc ) - Set callback function to receive Packet SDK asynchronous status.
static void UnSetCallBack() - Cancel the callback of Packet SDK.
static packet_status_t SetAppKey(string appkey )- (required) - Set application key for Packet SDK.
PACKET_SUCCESS - Successfully set the application key.
PACKET_APPKEY_INVALID - Invalid application key.
PACKET_APPKEY_DUPLICATESETTING - Application key duplicate setting.
static packet_status_t Start()- (required) - Start Packet SDK.
PACKET_SUCCESS - Successfully launched the Packet SDK.
PACKET_APPKEY_UNSET - Application key not set.
PACKET_SDK_RUNNING - Packet SDK is already in startup state.
static packet_status_t Stop() - Stop Packet SDK.
PACKET_SUCCESS - Successfully stop the Packet SDK.
PACKET_SDK_NOT_RUNNING - The Packet SDK is currently not in a startup state.
static packet_status_t QueryServerStatus() - Querying the current status.
PACKET_SDK_SERVER_CONNECTED - Connected.
PACKET_SDK_SERVER_DISCONNECTED - Disconnected.
static string StatusToString(packet_status_t status ) - Convert status to readable strings.
Last updated