Campaign Custom Endpoints (Android)

This article describes how to use campaign custom endpoints using the Android SDK.

Send More Variables to Campaign Custom Endpoints

When using Campaign custom endpoints, you may want to send additional data to the custom endpoint.

To do this, extend CampaignBroadcastReceiver to create a campaign receiver.

Then override the getUserInfoForCampaign method to add custom Campaign values.

/// Extend CampaignBroadcastReceiver
public class CampaignReceiver extends  CampaignBroadcastReceiver {

    @Override
    protected void onReceive(Context context, Intent intent, String title, String message) {

        Intent notificationIntent = new Intent(context, MainActivity.class);
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder.setContentTitle(title);
        builder.setContentText(message);
        builder.setSmallIcon(R.drawable.ic_launcher);
        builder.setDefaults(Notification.DEFAULT_ALL);
        builder.setContentIntent(contentIntent);
        builder.setAutoCancel(true);
        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        nm.notify("com.arubanetworks.meridiansamples.CampaignReceiver".hashCode(), builder.build());
    }

/// Define custom values being sent to the custom Campaign endpoint.
    @Override
    protected Map
 
   getUserInfoForCampaign(Context context, String campaignIdentifier) {
        HashMap
  
    map = new HashMap<>(); map.put("UserKey1", "userData1"); map.put("UserKey2", "userData2"); map.put("UserKey3", "userData3"); return map; } } 
  
 
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.