Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Clicks Tracking
Add click tracking to the activity creation method.
Code Block | ||||
---|---|---|---|---|
| ||||
if (intent.extras != null) { sdk.notificationClicked(intent.extras) } |
How To Use
Example show notification with download icon:
Code Block | ||||
---|---|---|---|---|
| ||||
object : AsyncTask<String?, Void?, Bitmap?>() { override fun doInBackground(vararg params: String?): Bitmap? { try { val inputStream = URL(params[0]).openStream() return BitmapFactory.decodeStream(inputStream) } catch (e: IOException) { e.printStackTrace() } return null } override fun onPostExecute(result: Bitmap?) { super.onPostExecute(result) val intent = Intent(applicationContext, MainActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) //REQUIRED! For tracking click notification intent.putExtra(PersonaClick.NOTIFICATION_TYPE, data["type"]) intent.putExtra(PersonaClick.NOTIFICATION_ID, data["id"]) val pendingIntent = PendingIntent.getActivity(applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE) val notificationBuilder = NotificationCompat.Builder(applicationContext, getString(R.string.notification_channel_id)) .setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(result) .setStyle(NotificationCompat.BigTextStyle().bigText(data["body"])) .setContentTitle(data["title"]) .setContentText(data["body"]) .setAutoCancel(true) .setContentIntent(pendingIntent) val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager notificationManager.notify(0, notificationBuilder.build()) } }.execute(data["icon"]) |
Token Send
Method Objective
The method allows manually sending an Android push notification token to the system.
Tip |
---|
The SDK sends a token to the system automatically. You can use this method if you need to send the token forcibly yourself. |
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.registerManager.setPushTokenNotification(android_token, callback); |
Name | Type | Requirement | Description |
---|---|---|---|
android_token | string | required | Android push notification token |
callback | function | optionally | The callback function to which the API response will be passed |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.registerManager.setPushTokenNotification( token = "93b033a394da31b3160b8e0a35b80b6c16eb99a22ed34e88afe2a117dd4bc601", listener = object : OnApiCallbackListener() { override fun onSuccess(msg: JSONObject?) { // API response processing functionality } } ) |
Payloads
The Payloads structures are available underĀ Push Payloads (Mobile SDKs).
Column | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Page Navigation
Related Pages
|