You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 3 Current »
Add click tracking to the activity creation method.
if (intent.extras != null) { sdk.notificationClicked(intent.extras) }
Example show notification with download icon:
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"])
The method allows manually sending an Android push notification token to the system.
The SDK sends a token to the system automatically. You can use this method if you need to send the token forcibly yourself.
sdk.registerManager.setPushTokenNotification(android_token, callback);
Android push notification token
sdk.registerManager.setPushTokenNotification( token = "93b033a394da31b3160b8e0a35b80b6c16eb99a22ed34e88afe2a117dd4bc601", listener = object : OnApiCallbackListener() { override fun onSuccess(msg: JSONObject?) { // API response processing functionality } } )
The Payloads structures are available under Push Payloads (Mobile SDKs).
Page Navigation
Related Pages