Versions Compared
Version | Old Version 2 | New Version Current |
---|---|---|
Changes made by | ||
Saved on |
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Add the code to your app.
Warning |
---|
Don't forget to replace the %YOUR_STORE_KEY% text with the current store key from your PersonaClick account. |
Code Block | ||||
---|---|---|---|---|
| ||||
class SampleApplication: Application() { private lateinit var sdk: SDK /** * Entry point for the application's activity where the SDK is initialized. * The SDK supports two types of initialization: * - **Basic Initialization:** Only the required parameters are provided for minimal configuration. * - **Extended Initialization:** Includes optional parameters for more advanced customization. * * You can choose the initialization method that best suits your application's needs. */ override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(); //Initialize val sdk = PersonaClick.getInstance() PersonaClick.initialize(applicationContext, savedInstanceState) sdk = SDK() /** * Initializes the SDK with a simple configuration. * This method is suitable if you only need the basic functionality of the SDK. * * @param context Context - Required. The application context used for SDK initialization. * @param shopId String - Required. The shop identifier, necessary for the SDK to function. * * @example * sdk.initialize( * context = applicationContext, * shopId = "%YOUR_STORE_KEY%" * ) //Notification callback sdk.setOnMessageListener(object : OnMessageListener { override fun onMessage(data: Map<String, String>) { //-----> //Show your custom notification //-----> } }) } } |
Code Block | ||||
---|---|---|---|---|
| ||||
PersonaClick.initialize(applicationContext, "%YOUR_STORE_KEY%", "%API_DOMAIN%") |
AndroidManifest.xml
and add android:name=".SampleApplication"
to application item.Code Block | ||||
---|---|---|---|---|
| ||||
<application
...
android:name=".SampleApplication" |
Code Block | ||||
---|---|---|---|---|
| ||||
{ "title" : "Message title", "body" : "Message body", "icon" : "Message large url image", "url" : "Url for open and tracking events"*/ sdk.initialize( context = context, shopId = "%YOUR_STORE_KEY%" ) /** * To display alerts, pass a fragment manager to the SDK. The fragment manager enables * the display of three types of alerts: * - centered on the screen * - positioned at the bottom * - full-screen * * To create a pop-up follow this way: * Account -> Pop-ups -> Programmatic pop-ups -> Create -> For mobile application */ sdk.initializeFragmentManager(fragmentManager = fragmentManager) /** * Initializes the SDK with an extended configuration. * This method provides additional options for advanced use cases. * * @param context Context - Required. The application context used for SDK initialization. * @param shopId String - Required. The shop identifier, necessary for the SDK to function. * @param apiDomain String? - Optional. The API domain that the SDK will interact with. Default is null. * @param tag String? - Optional. A tag used for configuring logs, making it easier to identify SDK messages. * Default value is "SDK," but you can specify your own tag name. * @param autoSendPushToken Boolean - Optional. Enables automatic token sending during initialization. Default is true. * @param needReInitialization Boolean - Optional. Allows you to reinitialize the SDK and clear the storage. Default is false. * * @example * sdk.initialize( * context = applicationContext, * shopId = "YOUR_SHOP_ID", * apiDomain = "YOUR_API_DOMAIN", * tag = "CustomTag", * autoSendPushToken = true, * needReInitialization = false * ) */ sdk.initialize( context = applicationContext, shopId = "%YOUR_STORE_KEY%", apiDomain = API_DOMAIN, tag = TAG, autoSendPushToken = true, needReInitialization = false ) } |
Column | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Related Pages
|