getCampaignId

open fun getCampaignId(): Long

Gets the campaign ID for this push notification.

The campaign ID uniquely identifies the push campaign that sent this notification. Use this for analytics, A/B testing tracking, campaign performance measurement, and correlating user actions with specific marketing campaigns. Example:


	  
	  protected void onMessageOpened(PushMessage message) {
	      long campaignId = message.getCampaignId();
	      long messageId = message.getMessageId();
	
	      // Track campaign conversion
	      analytics.trackCampaignConversion(campaignId);
	
	      // Log detailed campaign metrics
	      Log.d("Analytics", String.format(
	          "Campaign: %d, Message: %d opened at %s",
	          campaignId, messageId, new Date()
	      ));
	
	      // Check if this is from a special campaign
	      if (isBlackFridayCampaign(campaignId)) {
	          // Show special Black Friday offers
	          showBlackFridayDeals();
	      }
	  }
	
	  // Track campaign performance in e-commerce
	  
	  protected boolean onMessageReceived(PushMessage message) {
	      if (!message.isSilent()) {
	          long campaignId = message.getCampaignId();
	
	          // Store campaign info for attribution
	          SharedPreferences prefs = getSharedPreferences("app", MODE_PRIVATE);
	          prefs.edit()
	              .putLong("last_campaign_id", campaignId)
	              .putLong("campaign_received_time", System.currentTimeMillis())
	              .apply();
	      }
	      return false;
	  }
	

Return

campaign ID as a long value, or 0 if not available

See also