All pages
Powered by GitBook
1 of 1

Loading...

Use the SDK

1

Import the Library

Import the SDK to your file.

import PlaytimeMonetize
#import <PlaytimeMonetize/PlaytimeMonetize-Swift.h> 
import Playtime from 'react-native-adjoe-sdk-ios';
2

Initialize the SDK

To make all of the features of the Playtime SDK available, you need to initialize it first. This initialization happens asynchronously in the background.

3

Show the Catalog

It's required to pass userId here if auto-init is enabled.

Parameters

Parameter
Explanation

App Tracking

While the IDFA parameter is not required, we strongly recommend including it. It's purpose is to help attribute installs and ensure that users are rewarded.

The popup should be triggered in the app before calling showCatalog() . The user must then "Allow" tracking.

When a user selects "Play Now" in the Playtime Catalog, we use a pop-up to remind them to allow tracking.

Automatic

To trigger automatic initialization at the app's start, you should include the adjoe-playtime.plist file containing your SDK hash in your app's target. See the example file below:

Manual

To make all of the features of the Playtime SDK available, you need to initialize it first. This initialization happens asynchronously in the background.

Best Practices

  • Initialize the SDK immediately after the app launches.

  • Re-initialize the SDK and include the userId after the user has logged-in.

At app launch, call Playtime.initialize(...) . You can use application(_:didFinishLaunchingWithOptions:):

At app launch, call [Playtime initialize ...] . You can use application(_:didFinishLaunchingWithOptions:):

Call Playtime.initialize at the start of the application, for example, in the App.js's componentDidMount() method:

Call Playtime.showCatalog() to open a webview of the Playtime catalog:

Call [Playtime showCatalog] to open a webview of the Playtime catalog:

Call Playtime.showCatalog() to open a webview of the Playtime catalog:

placement

The placement of the Playtime Catalog inside your app, e.g., "Main Screen", "Shop", "Interstitial", "More Diamonds Screen", etc.

You can also choose to use adjoe's Apps feature, showing the Playtime catalog with distinct gaming or app experiences.

Option
Explanation

subId1

An optional identifier that is provided back in the S2S payout URL.

subId2

An optional identifier that is provided back in the S2S payout URL.

subId3

An optional identifier that is provided back in the S2S payout URL.

subId4

An optional identifier that is provided back in the S2S payout URL.

subId5

An optional identifier that is provided back in the S2S payout URL.

userId

A custom identifier you can assign to each user. If you haven't set one, the Playtime SDK generates it automatically. This ID is necessary for S2S payouts, thus required. Ensure this value is url-safe and that the value is never empty.

sdkHash

SDK hash that you received from the adjoe Monetize dashboard or Account Manager.

uaNetwork

User Acquisition Network. The network through which the user was acquired, e.g., Adwords, Facebook, or Organic.

uaChannel

User Acquisition Channel. The channel within the network from which the user was acquired, e.g. incentivized or video campaigns.

uaSubPublisherCleartext

The cleartext package name of the sub-publisher's app ID within the network from which the user was acquired, e.g., com.domain.appName.

uaSubPublisherEncrypted

The encrypted package name or app ID of the sub-publisher's app from the network where the user was acquired.

App Tracking Transparency
Task {
    do {
    
        let params = PlaytimeParamsBuilder()
                .setUANetwork("uaNetwork")
                .setUAChannel("uaChannel")
                .setUASubPublisherCleartext("uaSubPublisherCleartext"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    Task {
        do {
            try await Playtime.initialize(
                userID: "userId",
                sdkHash: "sdkHash",
                uaNetwork: "uaNetwork",
                uaChannel: "uaChannel",
                uaSubPublisherCleartext: "uaSubPublisherCleartext",
                uaSubPublisherEncrypted: "uaSubPublisherEncrypted",
                placement: "placement"
            )
        } catch {
            // handle errors / retry if needed
        }
    }
    return true
}
- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions
{
    [Playtime initializeWithUserID:@"userID"
                           sdkHash:@"sdkHash"
                         uaNetwork:@"uaNetwork"
                         uaChannel:@"uaChannel"
           uaSubPublisherCleartext:@"uaSubPublisherCleartext"
           uaSubPublisherEncrypted:@"uaSubPublisherEncrypted"
                         placement:@"placement"
                 completionHandler:^(NSError * _Nullable error) {
        if (!error) {
            NSLog(@"Playtime initialized successfully");
        } else {
            NSLog(@"Error initializing Playtime: %@", error);
        }
    }];
}
Playtime.initialize({
  sdkHash: "sdkHash",
  userId: "userId",
  uaNetwork: "uaNetwork",
  uaChannel: "uaChannel",
  uaSubPublisherCleartext: "uaSubPublisherCleartext",
  uaSubPublisherEncrypted: "uaSubPublisherEncrypted",
  placement: "placement"
})
.then(() => {
   console.log('Successful initialization!');
})
.catch((err) => {
   console.error(err);
});
PlaytimeParams *params = [[[[[[PlaytimeParamsBuilder alloc] init]
                           setUANetwork:@"uaNetwork"]
                          setUAChannel:@"uaChannel"]
                         setUASubPublisherCleartext:@"uaSubPublisherCleartext"]
                        setUASubPublisherEncrypted:@"uaSubPublisherEncrypted"]
                       setPlacement:@"placement"]
                      build];

PlaytimeExtensions *subIds = [[[[[[[[PlaytimeExtensionsBuilder alloc] init]
                                 setSubId1:@"subId1"]
                                setSubId2:@"subId2"]
                               setSubId3:@"subId3"]
                              setSubId4:@"subId4"]
                             setSubId5:@"subId5"]
                            build];

PlaytimeOptions *options = [[[[PlaytimeOptionsBuilder alloc] init]
                            setParams:params]
                           setExtensions:subIds]
                          build];

[Playtime showCatalogWithOptions:options
                   completionHandler:^(NSError * _Nullable error) {
        if (!error) {
            NSLog(@"Error showing Playtime catalog: %@", error);
        } else {
            NSLog(@"Did show catalog")
        }
    }];
Playtime.showCatalog({
  uaNetwork: "uaNetwork",
  uaChannel: "uaChannel",
  uaSubPublisherCleartext: "uaSubPublisherCleartext",
  uaSubPublisherEncrypted: "uaSubPublisherEncrypted",
  placement: "placement",
  subId1: "subId1",
  subId2: "subId2",
  subId3: "subId3",
  subId4: "subId4",
  subId5: "subId5"
})
.then(() => {
   console.log('Did show catalog!');
})
.catch((err) => {
   console.error(err);
});
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>sdkHash</key>
	<string>INSERT_YOUR_HASH_HERE</string>
</dict>
</plist>

both

Shows both gaming and non-gaming

)
.setUASubPublisherEncrypted("uaSubPublisherEncrypted")
.setPlacement("placement")
.build()
let subIds = PlaytimeExtensionsBuilder()
.setSubId1("subId1")
.setSubId2("subId2")
.setSubId3("subId3")
.setSubId4("subId4")
.setSubId5("subId5")
.build()
let options = PlaytimeOptionsBuilder()
.setParams(params)
.setExtensions(subIds)
.build()
try await Playtime.showCatalog(
options: options
)
} catch {
// handle errors / retry if needed
}
}

nongaming

Only shows non-gaming campaigns

gaming

Only shows gaming campaigns

When initializing the SDK, you should include additional User Acquisition and placement parameters. These parameters allow you to track and analyze Playtime's performance within your app.

You can provide these parameters in any combination, both at initialization and at any point in the app's lifecycle—such as when a user launches the Playtime Catalog interacts with a campaign or requests a payout.

These values must be url-safe as they could potentially be returned as query parameters in the S2S Payout request.

To make the most of the Playtime SDK, to maximize your revenue and provide the best user experience, use all of these parameters for data-driven optimizations. For instance, you can monitor the performance of different Playtime button placements or determine the effectiveness of different UA sources.