Initialization

In this section, we explain how to initialize the SDK within your app.

Prerequisites: Get your locationKey

You should have received a locationKey from StayTuned. This key allow us to identify your content within the platform.

When your app starts, configure the SDK with your StayTuned's appId and authToken so that it can make requests to the StayTuned API.

Android
iOS
Web
Cordova
Android
App.kt
import android.app.Application
import com.staytuned.sdk.Staytuned
class App: Application() {
override fun onCreate() {
Staytuned.init(
applicationContext,
<your-app-id>,
<your-auth-token>,
)
}
}
iOS
AppDelegate.swift
import UIKit
import StayTuned
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
StayTuned(appId: <your-app-id>, authToken: <your-auth-token>)
// do any other necessary launch configuration
// ....
// ....
return true
}
}
Web
import '@staytuned-io/sdk'
window.staytunedReady = () => {
staytunedSDK.init(
{
appId: '', // Your appID
authToken: '' // Your authToken
},
() => {
/**
* Callback function that will be called
* once Staytuned sdk initalisation ends
*/
}
)
}
Cordova
import { Staytuned } from "@staytuned-io/cordova-typescript";
Staytuned.getInstance().init("your-app-id", "your-auth-token").then(() => {
// on success
}).catch(() => {
// on error
});

We give you the opportunity to initialize the SDK with more options:

Android
Web
Cordova
Android
App.kt
import android.app.Application
import com.staytuned.sdk.Staytuned
class App: Application() {
override fun onCreate() {
val options = STOptions()
options.contentCachingOptions = STContentCachingOptions()
options.isPlayerNotificationDismissible = true
Staytuned.init(
applicationContext,
<your-app-id>,
<your-auth-token>,
stOptions,
)
}
}
Web
import '@staytuned-io/sdk'
window.staytunedReady = () => {
staytunedSDK.init(
{
appId: '', // Your appID
authToken: '', // Your authToken
opts: {
debug: true,
// ... See StaytunedGlobalFactoryOptions
}
},
() => {
/**
* Callback function that will be called
* once Staytuned sdk initalisation ends
*/
}
)
}
Cordova
import { Staytuned } from "@staytuned-io/cordova-typescript";
Staytuned.getInstance().init(
"your-app-id",
"your-auth-token"
).then(() => {
// on success
}).catch(() => {
// on error
});

For iOS, you can read all available options in "Customize theme" section.