Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Clicks Tracking

Add click tracking to the activity creation method.

Code Block
languagejava
themeFadeToGrey
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Click tracking
    if (getIntent().getExtras()intent.extras != null) {
        Personaсlicksdk.notificationClicked(getIntent().getExtras());
    }
}intent.extras)
}


How To Use

Example show notification with download icon:

Code Block
languagejava
themeFadeToGrey
newobject : AsyncTask<String?, Void?, Bitmap>Bitmap?>() {
 	@Override
	protected Bitmap   override fun doInBackground(String...vararg params: String?): Bitmap? {
		
        try {
			InputStream in = new
            val inputStream = URL(params[0]).openStream();
			
            return BitmapFactory.decodeStream(in);
		inputStream)
        } catch (e: IOException e) {
			            e.printStackTrace();
		}
		return null;
	}

	@Override
	protected void onPostExecute(Bitmap result) {
		
        }
        return null
    }

    override fun onPostExecute(result: Bitmap?) {
        super.onPostExecute(result);

        		Intentval intent = new Intent(getApplicationContext()applicationContext, MainActivity::class.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.get(["type"]));
        intent.putExtra(PersonaClick.NOTIFICATION_ID, data.get(["id"));

		PendingIntent])

        val pendingIntent = PendingIntent.getActivity(getApplicationContext()applicationContext, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

		NotificationCompat.Builder or PendingIntent.FLAG_IMMUTABLE)

        val notificationBuilder = new NotificationCompat.Builder(getApplicationContext()applicationContext, getString(R.string.notification_channel_id))
				
            .setSmallIcon(R.mipmap.ic_launcher)
				            .setLargeIcon(result)
				
            .setStyle(new NotificationCompat.BigTextStyle().bigText(data.get(["body"])))
				
            .setContentTitle(data.get(["title"))
				])
            .setContentText(data.get(["body"))
				])
            .setAutoCancel(true)
				
            .setContentIntent(pendingIntent);

        		NotificationManagerval notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
		if( notificationManager != null ) {
			 as NotificationManager
        notificationManager.notify(0, notificationBuilder.build());
		} else { 			Log.e(PersonaClick.TAG, "NotificationManager not allowed");
		}
	}
}.execute(data.get(["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
languagejava
themeFadeToGrey
PersonaClicksdk.registerManager.setPushTokenNotification(android_token, callback);


NameTypeRequirementDescription
android_tokenstringrequired

Android push notification token

callbackfunctionoptionallyThe callback function to which the API response will be passed

Example of use

Code Block
languagejava
themeFadeToGrey
PersonaClicksdk.registerManager.setPushTokenNotification(
    token = "93b033a394da31b3160b8e0a35b80b6c16eb99a22ed34e88afe2a117dd4bc601",
new Api.    listener = object : OnApiCallbackListener() {
	@Override
	public void
        override fun onSuccess(msg: JSONObject msg?) {
		
            // API response processing functionality
	}
});
        }
    }
)



Payloads

The Payloads structures are available under Push Payloads (Mobile SDKs).


Column

Page Navigation

Table of Contents
maxLevel1
indent0px
stylenone




Related Pages

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
sorttitle
cqllabel in ( "notifications" , "apppush" )