Upsight logo Back to top

Unity

Overview


The Upsight Unity Plugin currently supports the following platforms / versions:

  • iOS 5.1 and higher
  • Android API Level 10 and Android build and platform tools revision 20 and higher
  • Unity 4.3 and higher

Note This plugin has been completely rewritten. If you are upgrading from the legacy PlayHaven Unity Plugin, you will need to re-integrate. See the legacy migration guide for more details.

If you have any questions, visit the Publish Guide or contact Upsight Support. We also recommend reviewing our Optimization Guides to learn the best practices and get the most out of your Upsight integration.

Getting Started

Import the Plugin


  1. Download the Upsight Unity Plugin and double-click the file to import it into your project.

  2. Open the demo scene in the Plugins/Upsight/demo folder.

    The plugin includes a demo scene to show you how all the features work. It is preconfigured with an Upsight test account so you can run it on your device.

  3. Switch to either the iOS or Android platform from the build settings menu.

  4. Build and run the demo scene to familiarize yourself with the plugin. You must run the demo scene on a physical device. You cannot test Upsight functionality from the Unity editor.

    Watch the logs while pressing buttons to see all the events the plugin offers and when they are fired. After exploring the demo scene you will be ready to add Upsight to your Unity project.

Disable Automatic Reference Counting

If you are building an iOS project in Unity 5, you will need to disable Automatic Reference Counting. To do this, in your Build Phases, under Compile Sources, add -fno-objc-arc as a Compiler Flag to all the files in the Libraries/Plugins/iOS directories.

Some files that require the compiler flag

You also have the option to add -fno-objc-arc in Unity. To do so, locate the Upsight plugin in the Assets/Plugins/iOS/ folder. In the Inspector for each file, you should see "Compile Flags" towards the bottom. Adding -fno-objc-arc to this will allow Unity to compile the Xcode project with ARC turned off.

Link AdSupport Framework

If you are getting a Apple Mach-O Linker Error, your Unity Project did not import the AdSupport.framework library to Xcode correctly. To fix this, you will need to manually delete the library in the Project and add it again.

  1. In your Frameworks folder, delete the AdSupport.framework file.

  2. In your Build Phases, under the Link Binary With Libraries section, click the + (plus) button to add a framework.

  3. In the window that appears, select AdSupport.framework and click Add.

Getting Started

Initialize the Plugin


You must do the following in your own script to initialize the plugin properly.

  1. Call Upsight.init and Upsight.requestAppOpen at app launch.
  2. Call Upsight.requestAppOpen every time your app is opened after being backgrounded.

The sample code below shows how this is done. The script would need to be attached to a GameObject in your Unity project.

public class MyUpsightPlugin : MonoBehaviour
{
    // These values are from the demo scene.
    // Replace them with your own.
#if UNITY_ANDROID
    public string appToken = "a0ae2f5cd6dc465aaeaf4b05692ac3be";
    public string appSecret = "0e6deaf6ff0040c0963848d534bf1cb3";
#else
    public string appToken = "39da36bd4be24e18a54b367dc5407647";
    public string appSecret = "8c52361b93664202a783487944cb7477";
#endif

    void Start()
    {
#if UNITY_IPHONE || UNITY_ANDROID
        Upsight.init( appToken, appSecret );

        // Make an open request at every app launch
        Upsight.requestAppOpen();
#endif
    }

    void OnApplicationPause( bool pauseStatus )
    {
#if UNITY_IPHONE || UNITY_ANDROID
        // Make an open request whenever app is resumed
        if( !pauseStatus )
            Upsight.requestAppOpen();
#endif
    }
}

Important If you are using the Enterprise and regular SDKs, make sure to call the startSession method before making an requestAppOpen Open Call.

Getting Started

Create a Placement


Placement are hooks within your app that can trigger any type of Upsight content that you have configured in the Upsight Marketing Dashboard. Placements are created from the Upsight Marketing Dashboard.

In this example, you will create an app_launch placement.

  1. Log in to the Upsight Marketing Dashboard.
  2. Click on your app on the dashboard home page.
  3. Click on the “App Settings” button.
  4. Click on the “Placements” link.
  5. Create a placement tag named app_launch.

Getting Started

Add a Content Unit to Your Placement


Placements must contain at least one content unit to display. Content units are created and added to placements from the Upsight Marketing Dashboard.

In this example, you will add an Internal Cross-Promotion to your app_launch placement.

  1. Click on your app on the Upsight Marketing Dashboard home page.
  2. Click on the “add content” button.
  3. Click on on the Add Internal Cross-Promotion button.
  4. Enter Test Ad for the Internal Cross-Promotion name.
  5. Enter name of app(s) for Internal Cross-Promotion.
  6. Upload image(s) associated with Internal Cross-Promotion.
  7. Under “Placement(s)”, check the box for the app_launch placement you created.
  8. Click the “publish” button.

Getting Started

Make a Content Request


Make content requests from your app for specific placements whenever you wish to trigger Upsight content to be displayed. This will add placement hooks within your app that correspond to placements that you have created from the Upsight Marketing Dashboard.

In this example, you will make a content request for the app_launch placement each time your app launches. Be sure to make this call after you have initialized the Upsight Unity Plugin.

void Start()
{
#if UNITY_ANDROID
    Upsight.init( androidAppToken, androidAppSecret );
#else
    Upsight.init( iosAppToken, iosAppSecret );
#endif

    // Make an open request at every app launch
    Upsight.requestAppOpen();

    // Make a content request at every app launch
    Upsight.sendContentRequest( "app_launch", true );
}

Getting Started

Test Integration


Build your app and install it onto a device to test the integration. Please note that you will not be able to see Upsight content from the Unity editor. You must test from a physical device in order to see content.

Getting Started

Integration Checklist


To help make the integration process easier, we've created a checklist with troubleshooting tips that you can follow. If you are not getting expected results after integration, consults the checklist to see if there are any steps that you are missing.

Integration Checklist

Content Units

Content Unit Overview


All content units must be configured from the Upsight Marketing Dashboard. Once configured, you must make a content request from your app for a specific placement that contains the content unit you wish to display.

Some content units described below require additional coding in order to fully support.

Content Units

Announcements


Announcements are messages delivered to players in your app. See Help Center overview for more information.

No additional code is required to support this content unit.

Content Units

Internal Cross-Promotions


Internal Cross-Promotions are customizable promotions for your own apps. See Help Center overview for more information.

No additional code is required to support this content unit.

Content Units

More Games Widget


The More Games Widget is a non-interruptive content unit in your app featuring a list of app titles. Apps typically have a dedicated button in the main menu to request this content unit. See Help Center overview for more information.

No additional code is required to support a basic More Games Widget, but advanced functionality is available with additional coding.

The More Games Widget supports a notification badge count that can be used to visually indicate that there are new apps. Displaying this notification badge count on top of your More Games button can increase clicks. The following code shows how to get the notification badge count.

// Listen for the notification badge count event.
UpsightManager.badgeCountRequestSucceededEvent += myShowNotificationBadgeCountMethod;

// Get the notification badge count for the placement “more_games”.
// This placement must have a More Games Widget associated with it!
Upsight.getContentBadgeNumber( "more_games" );

The notification badge count will be passed to your custom method when the event fires.

void myShowNotificationBadgeCountMethod( int badgeCount )
{
    // Draw a notification badge on top of your More Games button
    // using the badgeCount
}

Content Units

Opt-In Data Collection


Opt-in Data Collection is a promotion that gives users the option to provide you with valuable information like email address, name, and age. See Help Center overview for more information.

No additional code is required to support this content unit.

Content Units

Rewards


Rewards are customized offers automatically awarded to your users. See Help Center overview for more information.

Additional coding is required to support rewards. After a reward content unit is displayed, the unlockedRewardEvent is fired for each reward item that you have configured for the content unit in the Upsight Marketing Dashboard. The unlockedRewardEvent can also be triggered by other content units, like Opt-In Data Collection.

// Listen for the unlocked reward event.
UpsightManager.unlockedRewardEvent += myUnlockedRewardMethod;

When a reward is unlocked, an UpsightReward will be passed to your custom method. Use this to give the reward to the user.

void myUnlockedRewardMethod( UpsightReward reward )
{
    // Give the user the UpsightReward that was unlocked
    //
    // reward.name - The name of your reward configured in the dashboard
    // reward.quantity - Integer quantity of the reward configured in the dashboard
    // reward.receipt - Unique identifier to detect duplicate reward unlocks. Your
    //                  app should ensure that each receipt is only unlocked once.
}

Content Units

Virtual Goods Promotion (VGP)


A Virtual Goods Promotion (VGP) is a customizable promotion used to increase in-app purchases. See Help Center overview for more information.

Additional coding is required to support VGPs. When a user clicks on a VGP content unit, the makePurchaseEvent is fired.

// Listen for the purchase event.
UpsightManager.makePurchaseEvent += myMakePurchaseMethod;

When the makePurchaseEvent fires, an UpsightPurchase will be passed to your custom method. Use this to initiate in-app purchases from your app. After the purchase completes, use trackInAppPurchase to track any purchase conversions. On Android, use the trackInAppPurchase( quantity, UpsightAndroidPurchaseResolution , price, sku, store, UpsightPurchase); to track conversions.

void myMakePurchaseMethod( UpsightPurchase purchase )
{ // Initiate an In-App Purchase for this item 
  // 
  // purchase.productIdentifier - The IAP product identifier / SKU 
  // purchase.quantity - Integer quantity of the purchase .... 
  // record the purchase 
#if UNITY_ANDROID 
Upsight.trackInAppPurchase( quantity, UpsightAndroidPurchaseResolution.Bought, price, orderId, store, purchase) 
#elif UNITY_IOS 
Upsight.trackInAppPurchase( productId, quantity, UpsightIosPurchaseResolution.Buy, receipt); 
#endif }

Push Notifications


To get started with Push Notifications, read our Push Notifications Overview page. For more information on the implementation portion of Push for Unity, read our Unity Push Notification Guide.

Advanced

COPPA


If COPPA applies to you, there is an “opt-out” status that can be used to indicate whether you want Upsight to limit data collection and use, and serve only contextually targeted ads.

By default, the “opt-out” status is set to false. You can change this at any time. To get or set the “opt-out” status, use the following methods:

// Get the opt-out status
Upsight.getOptOutStatus();

// Set the opt-out status
Upsight.setOptOutStatus( true );
Upsight.setOptOutStatus( false );

WARNING It is extremely important to understand the consequences of setting the opt-out status to true. By setting the opt-out status to true, advertising will be limited and platform data collection capabilities will be disabled. Currently, this means that when opt-out is set to true, no advertisements will be available in your apps.

Advanced

Custom Dimensions


You can target your marketing campaigns to a customized segment of users by creating custom dimensions. Once you have created custom dimensions in the Upsight Marketing Dashboard, you can add them to any content request from the SDK.

Important You must create custom dimensions in the Upsight Marketing Dashboard first before you can use them in the SDK. Please read this article for more information.

You can add custom dimensions as a Dictionary<string,object> to any content request, as shown below.

var dict = new Dictionary<string,object>();
dict.Add( "ua_source", "PlayHaven" );
dict.Add( "gold_balance", 2170 );
dict.Add( "registered", true );

// Pass in the custom dimensions dictionary
Upsight.sendContentRequest( "my_placement", true, false, dict );

You can also add custom dimensions when preloading.

var dict = new Dictionary<string,object>();
dict.Add( "ua_source", "PlayHaven" );
dict.Add( "gold_balance", 2170 );
dict.Add( "registered", true );

// Pass in the custom dimensions dictionary when preloading
Upsight.preloadContentRequest( "my_preloaded_placement", dict );

...

// Send the content request when you’re ready to display it
Upsight.sendContentRequest( "my_preloaded_placement", true );

Please note:

  • Upsight stores all custom dimensions received from the plugin on the server side for each device using your app.
  • The keys that you use in the plugin must match the keys that you created in the Upsight Marketing Dashboard.
  • Sending the same key with a different value for a device will update the custom dimension stored server side.
  • Sending a key with a null value for a device will delete the custom dimension stored server side.

Advanced

Custom Events


Send custom events when a user performs an action specific to your application. This action can be anything that you deem valuable to track, such as progression to another level in a game.

To send a custom event, create a Dictionary<string,object> representing the event properties you wish to track. The dictionary has the following restrictions:

  • The keys must be strings and the values must be strings, numbers, or dictionaries.
  • The dictionary size must be less than 100 KB.

Note The dictionary must conform to a specific structure in order for your events to be tracked correctly. The Upsight Event Designer does not generate C# code for Unity.

// Construct custom event dictionary
var dict = MiniJSON.Json.Deserialize( "{\"inventory\":{\"swords\":{\"katanas\":3}}}" )
               as Dictionary<string,object>;

// Send the custom event
Upsight.reportCustomEvent( dict );

Advanced

Preloading


Preloading can make content requests more responsive and potentially load faster. The performance improvements are more noticeable on Android because content is downloaded ahead of time.

Preloading requires two steps: preload the content unit, then display the content unit.

// Preload the content request well ahead of time
Upsight.preloadContentRequest( "my_preloaded_placement" );

...

// Send the content request when you’re ready to display it
Upsight.sendContentRequest( "my_preloaded_placement", true );

Note If you are preloading multiple different placements that display the same content unit, frequency caps for this content unit may not be applied.

Advanced

Remove IDFA on iOS


If you are not using the Advertising Identifier (IDFA) on iOS, you can completely remove it from the Upsight Unity Plugin.

  1. Switch to the iOS platform in your build settings.
  2. Select "Upsight" > "iOS IDFA Inclusion" > "Disable IDFA Access for Project" from the Unity menu.

    Upsight > iOS IDFA Inclusion > Disable IDFA Access

  3. Regenerate your Xcode project from Unity.

  4. Build your Xcode project.

Advanced

Tracking In-App Purchases


All In-App Purchases in your app should be tracked, regardless of whether Upsight VGPs triggered these purchases. Whenever an IAP completes (success or failure), make a simple tracking call as shown below. For Android VGPs, see following method.

// IAP tracking calls are platform-dependent
#if UNITY_IPHONE
// Receipt verification is supported on iOS
Upsight.trackInAppPurchase( "com.upsight.test.item"
                          , 1
                          , UpsightIosPurchaseResolution.Buy
                          , iapReceiptData );
#else
// Additional params are required for Android. Receipt verification not supported.
Upsight.trackInAppPurchase( "com.upsight.test.item"
                          , 1
                          , UpsightAndroidPurchaseResolution.Bought
                          , 2.99
                          , "the-order-id"
                          , "Google" );
#endif

Method Reference

deregisterForPushNotifications


Description

This method deregisters the current device for push notifications.

Signature

public static void deregisterForPushNotifications()

Required Parameters

No Required Parameters

Optional Parameters

No Optional Parameters

Method Reference

getContentBadgeNumber


Description

This method sends a request to get the badge count for the given placement.

Signature

public static void getContentBadgeNumber( string placement )

Required Parameters

NameTypeDescription
placementstringThis parameter is the placement tag configured in the dashboard. This placement should contain a More Games Widget in order for this method to return a badge count.

Optional Parameters

No Optional Parameters

Method Reference

getOptOutStatus


Description

This method returns the opt-out status. By default, the opt-out status is false.

Signature

public static bool getOptOutStatus()

Required Parameters

No Required Parameters

Optional Parameters

No Optional Parameters

Method Reference

getPluginVersion


Description

This method returns the plugin version.

Signature

public static string getPluginVersion()

Required Parameters

No Required Parameters

Optional Parameters

No Optional Parameters

Method Reference

init


Description

This method initializes the plugin. This must be called at app launch.

Signature

public static void init( string appToken, string appSecret, string gcmProjectNumber = null )

Required Parameters

NameTypeDescription
appTokenstringThe App Token.
appSecretstringThe App Secret.

Optional Parameters

NameTypeDescription
gcmProjectNumberstring The Google Cloud Messaging Project Number.

Note This parameter is Android only and optional. It is only required if you are using push notifications on Android.

Method Reference

preloadContentRequest


Description

This method preloads a content request. Results in the contentPreloadSucceededEvent and contentPreloadFailedEvent firing. You can later call sendContentRequest to send it.

Signature

public static void preloadContentRequest( string placement, Dictionary<string,object> dimensions = null )

Required Parameters

NameTypeDescription
placementstringThis parameter is the placement tag configured in the dashboard.

Optional Parameters

NameTypeDescription
dimensionsDictionary<String, object> This parameter is a dictionary that contains Custom Dimensions assigned to the content request. When setting a dimension, remember the following:
  • Dimension value must be string, numeric, or boolean type.
  • The Upsight server stores all custom dimensions received from each device.
  • You can remove a dimension for a given key on the server, by passing null as a dimension value.
  • Sending the same key with a different value will update the custom dimensions stored server-side.

Method Reference

registerForPushNotifications


Description

This method registers the current device for push notifications. This must be called at app launch in order to correctly handle pending notifications received after your app has been killed.

Signature

public static void registerForPushNotifications()

Required Parameters

No Required Parameters

Optional Parameters

No Optional Parameters

Method Reference

reportCustomEvent


Description

This method reports a custom event.

Signature

public static void reportCustomEvent( Dictionary<string,object> properties )

Required Parameters

NameTypeDescription
propertiesDictionary<string,object>A Dictionary containing the keys/values of the event.

Note The dictionary must conform to a specific structure in order for your events to be tracked correctly. Please use the Upsight Event Designer to construct your event data.

Optional Parameters

No Optional Parameters

Method Reference

requestAppOpen


Description

This method requests an app open. This must be called every time your app is opened, at launch and when resumed from the background. It will automatically check for any received push notifications and fire off the appropriate event if your app was launched from a push.

The openRequestSucceededEvent and openRequestFailedEvent events will also fire letting you know if the operation succeeded or failed.

Signature

public static void requestAppOpen()

Required Parameters

No Required Parameters

Optional Parameters

No Optional Parameters

Method Reference

sendContentRequest


Description

This method sends a content request for a given placement tag.

There are display options to show the loading overlay immediately and to animate the display. There is also the option to include custom dimensions.

Signature

public static void sendContentRequest( string placement, bool showsOverlayImmediately, bool shouldAnimate = true, Dictionary<string,object> dimensions = null)

Required Parameters

NameTypeDescription
placementstringThis parameter is the placement tag configured in the dashboard.
showsOverlayImmediatelyboolIf set to true, the method will show the content overlay immediately.

Optional Parameters

NameTypeDescription
shouldAnimateboolIf set to true the content request will be animated.
dimensionsDictionary<String, object> This parameter is a dictionary that contains Custom Dimensions assigned to the content request. When setting a dimension, remember the following:
  • Dimension value must be string, numeric, or boolean type.
  • The Upsight server stores all custom dimensions received from each device.
  • You can remove a dimension for a given key on the server, by passing null as a dimension value.
  • Sending the same key with a different value will update the custom dimensions stored server-side.

Method Reference

sendContentRequestWithContentUnitID


Description

This method sends a content request with the contentUnitID and messageID received from a push notification (pushNotificationWithContentReceivedEvent). In addition, you can specify custom dimensions to the content request.

Note This method is for iOS only.

Signature

public static void sendContentRequestWithContentUnitID( string contentUnitID, string messageID, bool showsOverlayImmediately, bool shouldAnimate = true, Dictionary<string,object> dimensions = null )

Required Parameters

NameTypeDescription
contentUnitIDstringThis parameter is the ID of the Content Unit.
messageIDstringThis parameter is the ID of the message.
showsOverlayImmediatelyboolIf set to true, the method will show the content overlay immediately.

Optional Parameters

NameTypeDescription
shouldAnimateboolIf set to true the content request will be animated.
dimensionsDictionary<String, object> This parameter is a dictionary that contains Custom Dimensions assigned to the content request. When setting a dimension, remember the following:
  • Dimension value must be string, numeric, or boolean type.
  • The Upsight server stores all custom dimensions received from each device.
  • You can remove a dimension for a given key on the server, by psasing null as a dimension value.
  • Sending the same key with a different value will update the custom dimensions stored server-side.

Method Reference

setLogLevel


Description

This method sets the log level for the Upsight SDK.

Note This method is for Android only.

Signature

public static void setLogLevel( UpsightLogLevel logLevel )

Required Parameters

NameTypeDescription
logLevelUpsightLogLevelThis is an enum that has the value of SUPPRESS, VERBONE, DEBUG, INFO, WARN, ERROR, or ASSERT.

Optional Parameters

No Optional Parameters

Method Reference

setOptOutStatus


Description

This method sets the opt-out status.

Signature

public static void setOptOutStatus( bool optOutStatus )

Required Parameters

NameTypeDescription
optOutStatusboolIf set to true the opt-out status of the Upsight Unity Plugin will be updated.

Optional Parameters

No Optional Parameters

Method Reference

setShouldOpenContentRequestsFromPushNotifications


Description

This method sets a flag indicating whether a push notification with content should be automatically opened.

Note This method is for iOS only.

Signature

public static void setShouldOpenContentRequestsFromPushNotifications( bool shouldOpen )

Required Parameters

NameTypeDescription
shouldOpenboolIf set to true content units from push notifications will be automatically opened when received.

Optional Parameters

No Optional Parameters

Method Reference

setShouldOpenUrlsFromPushNotifications


Description

This method sets a flag indicating whether a push notification with a URL should be automatically opened.

Note This method is for iOS only.

Signature

public static void setShouldOpenContentRequestsFromPushNotifications( bool shouldOpen )

Required Parameters

NameTypeDescription
shouldOpenboolIf set to true URLs from push notifications will be automatically opened when received.

Optional Parameters

No Optional Parameters

Method Reference

trackInAppPurchase [iOS]


Description

This method tracks an In-App Purchase on iOS.

Note This method is for iOS only.

Signature

public static void trackInAppPurchase( string productID, int quantity, UpsightIosPurchaseResolution resolutionType, byte[] receiptData = null )

Required Parameters

NameTypeDescription
productIDstringThis is the Product ID of the purchase.
quantityintThis is the quantity purchased.
resolutionTypeUpsightIosPurchaseResolutionThis is an enum that has the value of Buy, Cancel, Error, or Failure.

Optional Parameters

NameTypeDescription
receiptDatabyte[]This is the receipt from the In-App Purchase used for receipt verification..

Method Reference

trackInAppPurchase [Android]


Description

This method tracks an In-App Purchase on Android.

Note This method is for Android only.

Signature

public static void trackInAppPurchase( string sku, int quantity, UpsightAndroidPurchaseResolution resolutionType, double price, string orderId, string store )

Required Parameters

NameTypeDescription
skustringThis is the SKU of the purchase.
quantityintThis is the quantity purchased.
resolutionTypeUpsightAndroidPurchaseResolutionThis is an enum that has the value of Unset, Bought, Cancelled, Invalid, Owned, or Error.
pricedoubleThis is the total price of the purchase.
storestringThe name of the App Store (e.g. "Google").

Optional Parameters

No Optional Parameters

Method Reference

trackInAppPurchase [Android VGP]


Description

This method tracks In-App Purchases on Android with a provided UpsightPurchase object. Use this for tracking VGP Purchases.

Note This method is for Android only.

Signature

public static void trackInAppPurchase( int quantity, UpsightAndroidPurchaseResolution resolutionType, double price, string orderId, string store, UpsightPurchase purchase )

Required Parameters

NameTypeDescription
quantityintThis is the quantity purchased.
resolutionTypeUpsightAndroidPurchaseResolutionThis is an enum that has the value of Unset, Bought, Cancelled, Invalid, Owned, or Error.
pricedoubleThis is the total price of the purchase.
storestringThe name of the App Store (e.g. "Google").
purchaseUpsightPurchaseThe `UpsightPurchase` object returned from the `makePurchaseEvent` callback.

Optional Parameters

No Optional Parameters

Event Reference

badgeCountRequestFailedEvent


Description

This event is fired when a getContentBadgeNumber request fails or if the provided placement does not contain a badge count.

Signature

   public static event Action<string> badgeCountRequestFailedEvent;

Parameter Types

TypeDescription
stringThe error.

Event Reference

badgeCountRequestSucceededEvent


Description

This event is fired when a call to getContentBadgeNumber succeeds. It includes the badge count.

Signature

public static event Action<int> badgeCountRequestSucceededEvent;

Parameter Types

TypeDescription
intThe badge count.

Event Reference

contentDidDisplayEvent


Description

This event is fired after content is displayed. It includes the placement.

Note This event is iOS only.

Signature

public static event Action<string> contentDidDisplayEvent;

Parameter Types

TypeDescription
stringThe placement.

Event Reference

contentDismissedEvent


Description

Fired whenever content is dismissed. It includes the Placement ID and the dismiss type.

Signature

public static event Action<string, string> contentDismissedEvent;

Parameter Types

TypeDescription
stringThe Placement ID.
stringThe dismiss type.

Event Reference

contentPreloadFailedEvent


Description

This event is fired when a content preload fails. It includes the placement and error.

Signature

public static event Action<string, string> contentPreloadFailedEvent;

Parameter Types

TypeDescription
stringThe placement.
stringThe error.

Event Reference

contentPreloadSucceededEvent


Description

This event is fired when a content preload succeeds. It includes the placement.

Signature

public static event Action<string> contentPreloadSucceededEvent;

Parameter Types

TypeDescription
stringThe placement.

Event Reference

contentRequestFailedEvent


Description

This event is fired when a content request loads. It includes the placement and error.

Signature

public static event Action<string, string> contentRequestFailedEvent;

Parameter Types

TypeDescription
stringThe placement.
stringThe error.

Event Reference

contentRequestLoadedEvent


Description

This event is fired when a content request loads. It includes the placement.

Signature

public static event Action<string> contentRequestLoadedEvent;

Parameter Types

TypeDescription
stringThe placement.

Event Reference

contentWillDisplayEvent


Description

This event is fired when content will be displayed. It includes the placement.

Signature

public static event Action<string> contentWillDisplayEvent;

Parameter Types

TypeDescription
stringThe placement.

Event Reference

makePurchaseEvent


Description

This event is fired when a request to make a purchase occurs. It includes the Purchase.

Signature

public static event Action<UpsightPurchase> makePurchaseEvent;

Parameter Types

TypeDescription
UpsightPurchaseThe purchase.

Event Reference

openRequestFailedEvent


Description

This event is fired when an open request fails. It includes a string with the error.

Signature

public static event Action<string> openRequestFailedEvent;

Parameter Types

TypeDescription
stringThe error.

Event Reference

openRequestSucceededEvent


Description

This event is fired when an open request succeeds. It includes a Dictionary of all data returned.

Signature

public static event Action<Dictionary<string,object>> openRequestSucceededEvent;

Parameter Types

TypeDescription
Dictionary<string,object>All data returned.

Event Reference

pushNotificationWithContentReceivedEvent


Description

This event is fired when a push notification that contains content is received. It includes the Message ID and the Content Unit ID. These can be passed to the sendContentRequestWithContentUnitID method to display the content.

Note This event is iOS only.

Signature

public static event Action<string,string> pushNotificationWithContentReceivedEvent;

Parameter Types

TypeDescription
stringThe Message ID.
stringThe Content Unit ID.

Event Reference

pushNotificationWithUrlReceivedEvent


Description

This event is fired when a push notification that contains a URL is received. It includes the url.

Note This event is iOS only.

Signature

public static event Action<string> pushNotificationWithUrlReceivedEvent;

Parameter Types

TypeDescription
stringThe url.

Event Reference

reportCustomEventFailedEvent


Description

This event is fired when the reporting of a custom event fails. It includes the error.

Signature

public static event Action<string> reportCustomEventFailedEvent;

Parameter Types

TypeDescription
stringThe error.

Event Reference

reportCustomEventSucceededEvent


Description

This event is fired when the reporting of a custom event succeeds.

Signature

public static event Action reportCustomEventSucceededEvent;

Parameter Types

No Parameter Accepted

Event Reference

trackInAppPurchaseSucceededEvent


Description

This event is fired when an In-App Purchase succeeds.

Signature

public static event Action trackInAppPurchaseSucceededEvent;

Parameter Types

No Parameter Accepted

Event Reference

trackInAppPurchaseFailedEvent


Description

This event is fired when tracking an IAP fails. It includes the error.

Signature

public static event Action<string> trackInAppPurchaseFailedEvent;

Parameter Types

TypeDescription
stringThe error.

Event Reference

unlockedRewardEvent


Description

This event is fired when a reward is unlocked. It includes the Upsight reward object.

Signature

public static event Action<UpsightReward> unlockedRewardEvent;

Parameter Types

TypeDescription
UpsightRewardThe Upsight reward object.

Legacy PlayHaven Migration

Legacy Upgrade Steps


If you are upgrading from the legacy PlayHaven Unity Plugin, please follow these steps.

  1. Remove the legacy PlayHaven Unity Plugin from your unity project by deleting the following files and folders.

    Note Be careful not to delete a file that is also being used by your app or another 3rd party plugin.

    Assets/Editor/mod_pbxproj-readme.md
    Assets/Editor/mod_pbxproj.py
    Assets/Editor/PlayHaven
    Assets/Editor/PostprocessBuildPlayer
    Assets/Editor/PostprocessBuildPlayer_PlayHaven
    Assets/Editor Default Resources/PlayHaven
    Assets/Plugins/Android/AndroidManifest.xml
    Assets/Plugins/Android/build.xml
    Assets/Plugins/Android/default.properties
    Assets/Plugins/Android/libs/commons-lang-2.6.jar
    Assets/Plugins/Android/libs/gcm-client-3.jar
    Assets/Plugins/Android/libs/json-path-0.8.1.jar
    Assets/Plugins/Android/libs/json-smart-1.1.1.jar
    Assets/Plugins/Android/libs/playhaven.jar
    Assets/Plugins/Android/libs/PlayHavenFacade.jar
    Assets/Plugins/Android/libs/spring-android-core-1.0.1.RELEASE.jar
    Assets/Plugins/Android/libs/spring-android-rest-template-1.0.1.RELEASE.jar
    Assets/Plugins/Android/libs/support-v4-r7.jar
    Assets/Plugins/Android/local.properties
    Assets/Plugins/Android/res/drawable/playhaven.png
    Assets/Plugins/Android/res/drawable/playhaven_badge.xml
    Assets/Plugins/Android/res/drawable/playhaven_overlay.xml
    Assets/Plugins/Android/res/layout/playhaven_activity.xml
    Assets/Plugins/Android/res/layout/playhaven_dialog.xml
    Assets/Plugins/Android/res/layout/playhaven_exit.xml
    Assets/Plugins/Android/res/layout/playhaven_loadinganim.xml
    Assets/Plugins/Android/res/layout/playhaven_overlay.xml
    Assets/Plugins/Android/res/values/playhaven_attrs.xml
    Assets/Plugins/Android/res/values/playhaven_config.xml
    Assets/Plugins/Android/res/values/playhaven_styles.xml
    Assets/Plugins/Android/src/com/playhaven
    Assets/Plugins/iOS/JSON.h
    Assets/Plugins/iOS/libPlayHaven.a
    Assets/Plugins/iOS/PHAPIRequest.h
    Assets/Plugins/iOS/PHConnectionManager.h
    Assets/Plugins/iOS/PHConstants.h
    Assets/Plugins/iOS/PHContentView.h
    Assets/Plugins/iOS/PHNotificationView.h
    Assets/Plugins/iOS/PHPublisherContentRequest.h
    Assets/Plugins/iOS/PHPublisherIAPTrackingRequest.h
    Assets/Plugins/iOS/PHPublisherMetadataRequest.h
    Assets/Plugins/iOS/PHPublisherOpenRequest.h
    Assets/Plugins/iOS/PHPurchase.h
    Assets/Plugins/iOS/PHPushProvider.h
    Assets/Plugins/iOS/PHReward.h
    Assets/Plugins/iOS/PHUnityIntegration.h
    Assets/Plugins/iOS/PHUnityIntegration.mm
    Assets/Plugins/iOS/PHURLLoader.h
    Assets/Plugins/iOS/PlayHaven.bundle
    Assets/Plugins/iOS/PlayHavenSDK.h
    Assets/Plugins/iOS/SBJsonBase.h
    Assets/Plugins/iOS/SBJsonParser.h
    Assets/Plugins/iOS/SBJsonWriter.h
    Assets/Plugins/PlayHaven
    
  2. Follow the Getting Started guide for integrating the Upsight Unity Plugin into your unity project.

    Please note that you will not be able to build successfully until you complete the remaining steps below.

  3. Remove the PlayHavenManager GameObject and all references to it.

  4. Remove all ContentRequester GameObjects and replace all references with content request code calls to sendContentRequest.

  5. Replace legacy method calls with new method calls. See Replace Method Calls for more details.

  6. Replace legacy event handling with new event handling. See Replace Event Handling for more details.

  7. Test your changes by building your unity project.

Legacy PlayHaven Migration

Replace Method Calls


This table contains a mapping of commonly used legacy methods and the new methods to replace them.

Legacy MethodNew MethodNotes
ContentPreloadRequestpreloadContentRequest
ContentRequestsendContentRequest
DeregisterFromPushNoficationsderegisterForPushNotifications
OpenrequestAppOpenNew method must be called at app launch and when app resumes from background. customUDID parameter no longer supported.
OpenNotificationrequestAppOpenNew method must be called at app launch and when app resumes from background. customUDID parameter no longer supported.
ProductPurchaseTrackingRequesttrackInAppPurchase
RegisterForPushNotificationsregisterForPushNotificationsNew method must be called at app launch.

Legacy PlayHaven Migration

Replace Event Handling


This table contains a mapping of commonly used legacy events and the new events to replace them.

Legacy EventNew EventNotes
OnBadgeUpdatebadgeCountRequestSucceededEventThe new Upsight Unity Plugin only provides the ability to get the badge count for a More Games Widget. The badge UI display is no longer supported. You must display the badge count yourself.
OnDidDisplayContentcontentDidDisplayEventNew event is only supported on iOS.
OnDismissContentcontentDismissedEvent
OnErrorContentRequestcontentRequestFailedEvent
OnErrorMetadataRequestbadgeCountRequestFailedEvent
OnErrorOpenRequestopenRequestFailedEvent
OnPurchasePresentedmakePurchaseEvent
OnRewardGivenunlockedRewardEvent
OnShouldOpenContentFromRemotePushNotificationpushNotificationWithContentReceivedEventNew event is only supported on iOS. Please see Receiving Push Notifications.
OnShouldOpenURLFromRemotePushNotificationpushNotificationWithUrlReceivedEventNew event is only supported on iOS. Please see Receiving Push Notifications.
OnSuccessOpenRequestopenRequestSucceededEvent
OnSuccessPreloadRequestcontentRequestPreloadSucceededEvent
OnWillDisplayContentcontentWillDisplayEvent

Troubleshooting


Build Issues

MiniJSON.cs conflict with Prime31 plugins

Some older Prime31 plugins use MiniJSON.cs. If you have a build conflict with MiniJSON.cs, it is safe to delete this file from the Prime31 plugin and try building again.

Unable to merge android manifests

This is typically caused by an issue in your player settings or by having an older version of the Android SDK. Make sure the minimum API level you are targeting in your PlayerSettings is API level 10 (2.3.3) and that you have an up to date version of the Android SDK tools (20 or higher).

Google Play Services Plugin Conflict

This is caused by having the same library more than once in your project. To resolve this conflict, simply delete all but one instance of the Google Play Services Library from your project structure. For example if you had Google Play Services in the following directories in your Unity project:

../Plugin/Android/google-play-services_lib
../Plugin/Android/play-services-4.3.23.aar

Remove one of these two instances to resolve the issue.

Unity 5 and the Apple Mach-O Linker Error

If you are using Unity 5 to build an iOS project, you will need to disable Automatic Reference Counting and you may need to manually add the AdSupport.framework. For more information, click here.