Upsight logo Back to top

Content Unit Types

Anouncements


Announcements are messages delivered to players in your app. Use the Upsight Dashboard to set up an announcement. No additional code is required.

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.

More Games Widget


Upsight’s More Games Widget displays specific apps that you decide to promote. Use the Upsight Dashboard to determine what apps are being displayed in your More Games Widget.

The More Games button is a standard Android button so you can specify it in XML or in Java. The following is an example specifying the button with XML.

<com.playhaven.android.view.MoreGames
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawablePadding="2sp"
    android:id="@+id/more"
    android:text="@string/moregames.text"
    android:onClick="moreGamesClicked"
    playhaven:placementTag="@string/moregamesexample.tag"
    playhaven:badgeTextColor="@color/cornsilk"
    />

In the example we specify values for the playhaven:placementTag and playhaven:badgeTextColor properties. The former is for specifying the placement tag we defined on the Upsight Dashboard, and the latter is the color for the number on the badge.

Next we will implement the RequestListener.

implements RequestListener
...
@Override
public void handleResponse(Context context, String json) {
}

@Override
public void handleResponse(Context context, PlayHavenException e) {
}

And add it to our Open request.

OpenRequest open = new OpenRequest();
open.setResponseHandler(this);
open.send(this);

Then, we will want to implement the handleResponse method to update the More Games badge. We do it this way because the Open request must be complete before making this request.

/**
 * Now that the Open is complete, tell the Badge to update
 */
 ((MoreGames) findViewById(R.id.more)).load(this);

Finally, we implement a moreGamesClicked method. This is really just a startActivity method moved into our new method.

/**
 * Now we start the new Activity.
 * Once the ad is closed, this Activity will be resumed.
 */
 startActivity(FullScreen.createIntent(this, getResources().getString(R.string.moregames_tag)));

Opt-In Data Collection


Opt-In Data Collection is an in-app promotion that gives players the option to provide you with valuable information like their email address, name, or age. Use the Upsight Dashboard to display an Opt-In Data Collection Content Unit in the same way that other Content Units are displayed. No additional code is required.

Rewards


Rewards are items you define that are given to your users using the Upsight infrastructure. Any content unit can contain a reward for your user. See Help Center overview for more information.

To add a reward to your application, you must:

  • replace the startActivity call with a startActivityForResult call.
  • have a content request that uses a placement that will give you a reward content unit from your Upsight dashboard.
  • add logic to the onActivityResult method to handle any Rewards messages that arrive.

For more information on using the startActivityForResult call and the onActivityResult method, please see the Content Result section.

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data){
  if(requestCode != EXAMPLE_REWARD_REQUEST_CODE) return;

  Bundle adData = data.getBundleExtra(PlayHavenView.BUNDLE_DATA);
  if(adData == null) return;

  for(Reward reward : adData.<Reward>getParcelableArrayList(PlayHavenView.BUNDLE_DATA_REWARD))
    Log.d(TAG, "Reward Collected:  " + reward);
}

In this example we:

  • Check if the request code matches the unique ID we assigned to Rewards and exit if it does not match.
  • Grab the BUNDLE_DATA from the Intent using the getBundleExtra method.
  • Check if the Bundle Data exists and exit if it does not.
  • Extract any granted BUNDLE_DATA_REWARD objects from the Bundle Data.
  • Log the reward.

This line returns an ArrayList<Parcelable> from the adData Bundle (using the BUNDLE_DATA_REWARD key) and casts it to an ArrayList<Reward>:

  for(Reward reward : adData.<Reward>getParcelableArrayList(PlayHavenView.BUNDLE_DATA_REWARD))

If you want to avoid using Generics you could, alternatively, do:

for(Parcelable parcel : adData.getParcelableArrayList(PlayHavenView.BUNDLE_DATA_PURCHASE))
{
    Purchase purchase = (Purchase) parcel;
    Log.d(TAG, "Purchase: (" + purchase.getSKU() +") " + purchase.getTitle());
}

Similarly, you could change the logs to be more explicit by printing the quantity and tag.

Log.d(TAG, String.format("Reward Collected: %d %s\n", reward.getQuantity().intValue(), reward.getTag() ));

Virtual Goods Promotion


A Virtual Goods Promotion (VGP) is a full-display promotion used to increase in-app purchases.

If the Upsight servers are made aware that a given user has already purchased a non-consumable In-App Purchase item, it will not show Virtual Goods Promotion Content Units for that item to that user. This is to avoid showing the user a promotion for an item that they have already purchased.

To add a purchase to your application, you must:

  • replace the startActivity call with a startActivityForResult call.
  • have a content request that uses a placement that will give you a VGP content unit from your Upsight dashboard.
  • add logic to the onActivityResult method to handle any VGP messages that arrive.

For more information on using the startActivityForResult call and the onActivityResult method, please see the Content Result section.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if(requestCode != EXAMPLE_VGP_REQUEST_CODE)
    return;

  PlayHavenView.DismissType dismissType = (PlayHavenView.DismissType) data.getSerializableExtra(PlayHavenView.BUNDLE_DISMISS_TYPE);
  if(dismissType != PlayHavenView.DismissType.Purchase) return;

  Bundle adData = data.getBundleExtra(PlayHavenView.BUNDLE_DATA);
  if(adData == null) return;

  for(Purchase purchase : adData.<Purchase>getParcelableArrayList(PlayHavenView.BUNDLE_DATA_PURCHASE))
    Log.d(TAG, "Purchase: (" + purchase.getSKU() +") " + purchase.getTitle());
}

In this example we:

  • Check if the request code matches the unique ID we assigned to Virtual Goods Promotion and exit if it does not match.
  • Grab the BUNDLE_DISMISS_TYPE from the Intent using the getSerializableExtra method.
  • Check if the Dismiss Type is a Purchase and exit if it does not.
  • Grab the BUNDLE_DATA from the Intent using the getBundleExtra method.
  • Check if the Bundle Data exists and exit if it does not.
  • Extract any granted BUNDLE_DATA_PURCHASE objects from the Bundle Data.
  • Log the purchases's SKU and title.

This line returns an ArrayList<Parcelable> from the adData Bundle (using the BUNDLE_DATA_PURCHASE key) and casts it to an ArrayList<Purchase>:

for(Purchase purchase : adData.<Purchase>getParcelableArrayList(PlayHavenView.BUNDLE_DATA_PURCHASE))

If you want to avoid using Generics you could, alternatively, do:

for(Parcelable parcel : adData.getParcelableArrayList(PlayHavenView.BUNDLE_DATA_PURCHASE))
{
  Purchase purchase = (Purchase) parcel;
  Log.d(TAG, "Purchase: (" + purchase.getSKU() +") " + purchase.getTitle());
}