Quickstart
Import the Tapjoy Unity plugin into your project to enable SDK integration. The Quickstart walk-through guides you through importing the .unitypackage, configuring SDK keys, and adding the required Tapjoy GameObject.
Read time 4 minutesLast updated 3 hours ago
SDK Integration
The first step in integrating with your app is to download the Unity SDK itself. The Tapjoy Unity Plugin zip contains a Unity package file for easy importing, and the raw files for those who prefer to drag-n-drop files for their Tapjoy upgrade. To import theTapjoyUnityPlugin_vVERSION.unitypackage
- Open your Unity project
- Assets > Import Package > Custom Package
- Point to the file
TapjoyUnityPlugin_vVERSION.unitypackage
- Review the list of import files checking for any conflicts
- Press the "Import" button to accept the files
Starting with 12.8.0, the Offerwall SDK is now managed by using Cocoapods by the External Dependency Manager. Ensure your Cocoapods version is 1.9.0 or greater and your Xcode version is 11.0 or greater
Updating on Unity 5.4 or higher
If you are updating your integration and you are using Unity 5.4 or higher, you will see a "fix" button that allows you to correct an error involving the Google Play Services library being marked for inclusion in iOS builds. Select Fix to ensure that Google Play Services is only included in Android builds. For versions of Unity earlier than 5.4, you will have to manually ensure that google-play-services_lib is set to be included only with Android builds. Note that n****ew integrations do not need this fix and will not see this button.Add App Permissions (for Android)
TheACCESS_WIFI_STATE
<manifest ...> ... <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> ... </manifest>
Connect to Tapjoy
You can start configuing Tapjoy in the Tapjoy Window. Go toWindow > Tapjoy

- Set the SDK Key for Android and iOS
- Add the Store name for Android market (for example, Google or Amazon)
- Enabling or disabling use of Advertising ID, Persistent ID, and IDFA
- Disable Advertising Id: This checkbox has the same effect as the DISABLE_ADVERTISING_ID_CHECK connect flag in Android. By default, Tapjoy’s Android SDK checks for the existence of the Google Advertising Identifier and will fail to initialize if it does not find it. By checking this box, you can disable this check so that the Offerwall SDK initializes even if there is no Google Advertising Identifier present. This is useful when Google Play Services is not present in the app, such as when you are making a build for release in a non-Google Play app store.
- Disable Persistent Ids: This checkbox has the same effect as the DISABLE_PERSISTENT_IDS connect flag in Android. The Offerwall SDK sends persistent identifiers (such as MAC address and Android Identifier) to Tapjoy servers to be used as fallback advertising identifier for the cases where advertising identifiers are not available (an option suggested in the Play Console Help documentation on Advertising ID). If this flag is set, persistent identifiers are sent to Tapjoy servers for advertiser tracking purposes only if the Advertising Identifier is unavailable within the SDK.
- There is no checkbox equivalent to the DISABLE_ANDROID_ID_AS_ANALYTICS_ID connect flag. (If this flag is set, the ID that Tapjoy uses for analytics purposes is not a copy of the Android ID, but instead a randomly generated string of characters. Releasing a build that changes the setting of this flag from the previous version might result in some of your existing users being seen as new users by Tapjoy’s analytics tools.) If you want to set this flag, you will have to use the Tapjoy Unity manual connect and add the DISABLE_ANDROID_ID_AS_ANALYTICS_ID flag.
- Setting the logging level.
Max User Level
You can tell Tapjoy how many levels there are in your game. You can set this value before or after calling connect.Tapjoy.SetMaxLevel(10);
User Segment
You can identify users as part of a segment by callingsetUserSegment
Tapjoy.SetUserSegment(TJSegment.VIP); Tapjoy.SetUserSegment(TJSegment.Payer); Tapjoy.SetUserSegment(TJSegment.NonPayer); Tapjoy.SetUserSegment(TJSegment.Unknown);
Manual Connect
The Unity SDK allows you to control your connection step through code. By default the SDK will handle connection for you. To gain manual control, first uncheck the "Auto-Connect" option in the Tapjoy Settings Window (Window > Tapjoy). When that option is unchecked the SDK will no longer automatically handle the connection for you. You will need to handle the connection with your code, this behavior is just like in the Native SDKs. When your application first starts up, you must callConnect
The other version of Connect takes a second parameter, a Dictionary of string/string values. This dictionary is your connectFlags, and they behave the same as in the Native SDKs.#if UNITY_ANDROID Tapjoy.Connect("your_android_sdk_key"); #elif UNITY_IOS Tapjoy.Connect("your_ios_sdk_key"); #endif
You can also get and set the logging level programmatically.Dictionary<string,string> connectFlags = new Dictionary<string,string>(); connectFlags.Add("TJC_OPTION_USER_ID", "<USER_ID_HERE>"); #if UNITY_ANDROID Tapjoy.Connect("your_android_sdk_key", connectFlags); #elif UNITY_IOS Tapjoy.Connect("your_ios_sdk_key", connectFlags); #endif
Before you can perform other actions with the SDK (such as loading ads), the SDK connection must complete. There are two event delegates that are triggered by connection events – OnConnectSuccess and OnConnectFailure. Declare delegate functions to listen for the connection events. When onConnectSuccess has fired you can begin using the other SDK functions. Should the SDK fail to connect, you can re-attempt the Connection by calling Connect() with no parameters. This will make the SDK re-try it’s connection using the SDK key that it last attempted to connect with.// Set logging level Tapjoy.SetLoggingLevel(LoggingLevel.Debug); // Get logging level LoggingLevel loggingLevel = Tapjoy.GetLoggingLevel();
Callbacks
Now that you have the SDK running, it’s time to take a moment to code for best practices. Before the Offerwall SDK can request ads or send tracking data, it needs to successfully connect to our servers. The SDK exposes a delegate functionOnConnectSuccess
OnConnectWarning
connectSuccess
OnConnectFailure
You can also check the booleanTapjoy.OnConnectSuccess += HandleConnectSuccess; ... public void HandleConnectSuccess() { Debug.Log ("Connect Success"); // Now that we are connected we can start preloading our placements TJPlacement p = TJPlacement.CreatePlacement("my_placement"); p.RequestContent(); } Tapjoy.OnConnectWarning += HandleConnectWarning; ... void HandleConnectWarning(int code, string message) { } Tapjoy.OnConnectFailed += HandleConnectFailed ... public void HandleConnectFailed(int code, string message){ }
Tapjoy.isConnected