Use the SDK
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.
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:
<?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>
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:):
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
}
Show the Catalog
It's required to pass userId here if auto-init is enabled.
Call Playtime.showCatalog()
to open a webview of the Playtime catalog:
Task {
do {
let params = PlaytimeParamsBuilder()
.setUANetwork("uaNetwork")
.setUAChannel("uaChannel")
.setUASubPublisherCleartext("uaSubPublisherCleartext")
.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
}
}
Parameters
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.
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.
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.
nongaming
Only shows non-gaming campaigns
gaming
Only shows gaming campaigns
both
Shows both gaming and non-gaming
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.
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 App Tracking Transparency 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.
Last updated