getLong

open fun getLong(key: String, defaultValue: Long): Long

Retrieves a long tag value by name, with a fallback default value.

Returns the long value associated with the given key. If the tag doesn't exist or cannot be converted to a long, returns the provided default value. This method is commonly used for timestamps and large numeric IDs.

Example (Subscription Management):


	TagsBundle tags = getUserTags();
	
	long userId = tags.getLong("user_id", 0L);
	long registeredAt = tags.getLong("registered_at", 0L);
	long subscriptionEnd = tags.getLong("subscription_end", 0L);
	
	// Check if subscription is expiring soon
	long now = System.currentTimeMillis();
	long daysUntilExpiry = (subscriptionEnd - now) / (24 * 60 * 60 * 1000);
	
	if (daysUntilExpiry <= 7 && daysUntilExpiry > 0) {
	    showRenewalReminder();
	}
	

Return

tag value as long, or defaultValue if tag is not found or not a number

Parameters

key

tag name (e.g., "user_id", "registered_at", "subscription_end")

defaultValue

value to return if tag doesn't exist or cannot be converted to long