SDK

1. Requesting a Placement

Create an instance of TJPlacement and initialize it with your placement name. Be sure the placement name string in your code matches the placement name in the dashboard exactly. You can also implement a delegate to receive callbacks (explained below).

TJPlacement placement = await TJPlacement.getPlacement();

Now you can request the content.

placement.requestContent();

NB: Before you request content please ensure that the Tapjoy connect call has succeeded. Do not make a request before you have received the onConnectSuccess callback.

2. Pre-caching the content

For the best user experience, you should request content in advance of when the user might be shown that content. For example, if the placement is a button on your main menu, you might want to request content for it when your application starts, just after the Tapjoy Connect call succeeds. If you wait until the last moment to request content, it is likely the user will have to wait for the content to load, and watch a loading spinner. For ads, this makes the user less likely to interact with the ad, and therefore less likely to make money for you.

3. Callbacks

To get feedback on the status of the content request, implement the following callbacks:

TJPlacement placement = await TJPlacement.getPlacement(placementName: 'placementName',
    onRequestSuccess: (placement) {},
    onRequestFailure: (placement, error) {},
    onContentReady: (placement) {},
    onContentShow: (placement) {},
    onContentDismiss: (placement) {}
);

4. Displaying a Placement

To actually display content, use placement.showContent();

You should check to make sure that content is ready before showContent():

if (await placement.isContentReady()) {
  placement.showContent();
}

NB: you should mute your app’s audio before showing content from a placement that might include video, otherwise the audio for the video and your app’s audio might conflict.

Often, it is a good idea to wait until the onContentReady callback fires before showing content to the user. This way, you can be sure that the content is actually on the device, and can be shown to the user without delay. Another equivalent way is to check to see if p.isContentReady() is true, as in the example above.

NB: In order to ensure proper functionality, prior to creating a placement object, the Tapjoy connect call needs to have been made and succeeded.

5. Re-requesting the content

Once you successfully display content from a placement to a user, you must request content again (i.e. call placement.requestContent(); again) to "reload" the placement with another content unit. You cannot simply call placement.showContent(); again. If you try to show content before requesting content, the show content will fail.

6. Setting the Entry Point

You can optionally tell Tapjoy the 'entry point' of each placement. There are a variety of preset values to choose from:

TJEntryPoint.entryPointUnknown;
TJEntryPoint.entryPointOther
TJEntryPoint.entryPointMainMenu
TJEntryPoint.entryPointHUD
TJEntryPoint.entryPointExit
TJEntryPoint.entryPointFail
TJEntryPoint.entryPointComplete
TJEntryPoint.entryPointInbox
TJEntryPoint.entryPointInit
TJEntryPoint.entryPointStore

You should set the entry point after creating your placement object, but before requesting content:

TJPlacement placement = await TJPlacement.getPlacement("myPlacement");
placement.setEntryPoint(TJEntryPoint.entryPointMainMenu);
placement.requestContent();