For Unity, a properly functioning integration cannot be made without following our documentation.
Skipping over important steps to immediately download the Plugin may result in a much more difficult integration and poor performance of any integration built.
SDK Download
If you need a quick download of the most recent version of the DT Unity Plugin, import the following package into your project, which can be downloaded here:
iOS Integration
If you are integrating OfferWall Edge for iOS on Unity, you will need an extra package, which you can download here:
Cocoapods
Alternatively, you could skip the process of integrating any package and directly edit your Podfile in the exported Xcode project.
Adding the following pod will make your integration ready:
pod 'FyberSDKUnityBridge', '~> 9.2.6'
Removing Current Plugin
If you are updating the Plugin, first make sure there is no trace of the previous version of the DT Offer Wall Edge Plugin. If you are integrating the plugin for the first time, you can jump straight to Step 1.
Simply remove the OfferWallEdge folder. This is a fail-safe way to ensure no legacy file is left behind:
If your current DT Offer Wall Edge Plugin pre-dates version 9.2.0 refer to Migrating from the Old to New Structure below to ensure it is correctly removed.
Migrating from Old to New Structure
Before DT Offer Wall Edge Unity Plugin 9.2.0, the plugin resources would be spread out across unity folders:
Starting from version 9.2.0 we have moved all relevant resources inside a DT Offer Wall Edge folder.
This makes it more convenient when updating the plugin and helps maintain the organization of the project folders.
If you are moving from a previous version, make sure to delete all traces of the DT Offer Wall Edge plugin before importing the new package.
These are all the files you must delete:
Assets/Fyber/
Assets/Plugins/Android/fyber-*.jar
Assets/Plugins/iOS/fyber-sdk-lib
Assets/Plugins/iOS/fyber-unity-bridge
Assets/Plugins/iOS/Fyber.projmods
This prevents build issues due to file duplications. Moving forward, the update process should be seamless.
Step 1: Adding the DT Unity Plugin to your Project
Before starting to code, you must set up the environment.
-
Download the latest version of the DT Unity Plugin. Feel free to check the Unity Changelog.
-
Import the provided
FyberUnityPlugin-xxx.unitypackage
assets package into your project by clicking on Assets → Import Package → Custom Package, from the Unity Editor.
-
The Unity package includes files for both platforms, iOS and Android.
-
If you are updating from a previous plugin version, it's recommended to delete the plugin files from your project before importing the new version.
There are additional steps to setup if you are going to deploy for Android:
Step 2: Adding User Consent
GDPR
The General Data Protection Regulation requires you to scope your user's consent. A user is within the GDPR scope for your app when one or all of the following apply:
- The user is currently located in the EU
- The user has registered with the app as an EU resident
- The app is specifically targeted to EU users
Once you have collected the user’s consent, you can pass them onto the SDK using the following API:
public static void SetGdprConsent(Boolean isGdprConsentGiven)
isGdprConsentGiven
is a boolean.
- true means you have the user’s consent.
- false means you do not have the user's consent
UserInfo.SetGdprConsent(true);
We recommend that the first time you gather the user’s consent, you pass it onto the SDK before starting the SDK. The SDK will then take the user’s consent into consideration when initializing. In the following sessions, you will only need to call the API if the user updates his or her consent.
More information on GDPR can be found under the GDPR Resource Page and FAQs.
For details of the CCPA - Privacy String, click here.
CCPA - Privacy String
The intention of the California Consumer Privacy Act of 2018 (CCPA) is to protect the personal information of California residents. CCPA applies to all companies doing business in California. If a California resident uses an app developer’s mobile app, CCPA applies to the developer and every company that processes the personal information of the app’s users.
CCPA came into effect on 1 January 2020.
For more information on DT and CCPA, refer to DT’s Resource Page.
For more information about CCPA, refer to the IAB CCPA Compliance Framework.
Setting the IAB US Privacy String
We recommend that the first time you gather a user opt-out (aka 'consent'), you pass it onto the SDK before initializing it. The SDK takes the user opt-out into consideration when initializing.
Once you have collected the user’s opt-out, you can pass it onto the SDK using the following API:
To set the IAB US privacy string, use the following API:
var consentString = "1YNN";
User.SetIABUSPrivacyString(consentString);
To clear the user opt-out setting, use the following API:
User.ClearIABUSPrivacyString();
Step 3: Starting the Plugin
Start the DT Unity Plugin before being able to use any DT product.
Warning
- Starting up the DT SDK when the main thread is performing a heavy operation (loading assets, etc) can result in an unresponsive state (for example, an ANR). This may lead to the app being down ranked in the app store. This is especially true for slower devices. For these reasons, It is advised to initialize the DT SDK after all the heavy operations are completed.
- You must initialize the SDK on app start for accurate DAU calculations.
To do this, determine a point in your application’s code that runs when the application starts and add the following code to that script.
First, include the FyberPlugin
namespace.
using FyberPlugin;
Now start the DT Unity Plugin!
Fyber.With(appId)
.WithUserId(userId)
.WithSecurityToken(securityToken)
.Start();
The securityToken
and appId
are required, and can be found in the Settings of your app in the Dashboard. The userId
should uniquely identify the user of your app.
DT requires User IDs to be unique within your app. You may not hardcode or share User IDs. If necessary, the DT Unity Plugin can assign unique User IDs for you (see below).
Automatically Generated User IDs
If you do not want to set a userId
yourself and would rather the DT Unity Plugin create it for you, the DT Unity Plugin will do so when you omit the call to .withUserId
in your code:
using FyberPlugin;
[...]
Fyber.With(appId)
.WithSecurityToken(securityToken)
.Start();
This generates the required unique userId
on the first launch of the application and stores it for subsequent launches.
Subsequent usage of the DT Unity Plugin during your application's lifecycle will reuse the parameters passed to this call. If the user re-installs the app, a new userId
will be generated.
Omit the userId is not DT's preferred method to start the DT Unity Plugin, especially if you are planning to user server-side callbacks to handle the user rewarding.
Handling Native Exceptions
You can subscribe to the event FyberCallback.NativeError
to catch and handle exceptions occurring within the native Plugin.
void OnEnable()
{
FyberCallback.NativeError += OnNativeExceptionReceivedFromSDK;
}
void OnDisable()
{
FyberCallback.NativeError -= OnNativeExceptionReceivedFromSDK;
}
public void OnNativeExceptionReceivedFromSDK(string message)
{
//handle exception
}
DT Logging
You can check if the DT Unity Plugin is starting, and other products (added later) are working as expected, looking at the logs.