You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 2 Next »
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 Payloads structures are available under Push Payloads (Mobile SDKs).
Page Navigation
Related Pages