Message
NotificationMessage
Region
PushKeys
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
Package: com.salesforce.marketingcloud.pushmodels
Module: Push Models Module v1.0.2
SDK: Salesforce Marketing Cloud Unified SDK 11.0.0
Region is a data class representing a geographic or beacon region in the Salesforce Marketing Cloud SDK. It provides functionality for managing both geofence regions and proximity beacon regions.
1data class Region : Parcelable, Comparable<Region>Parcelable - Enables Android inter-component communicationComparable<Region> - Allows sorting and comparison operationsAs a data class, Region has a primary constructor with the following parameters:
1Region(
2 center: LatLon,
3 description: String?,
4 id: String,
5 major: Int,
6 messages: List<Message>,
7 minor: Int,
8 name: String?,
9 proximityUuid: String?,
10 radius: Int,
11 regionType: Int
12)All properties are annotated with @JvmField for direct field access from Java:
| Property | Type | Description |
|---|---|---|
center | LatLon | The geographic center coordinates of the region |
description | String? | Optional textual description of the region |
id | String | Unique identifier for the region |
major | Int | Major value (typically used for beacon regions) |
messages | List<Message> | Collection of messages associated with this region |
minor | Int | Minor value (typically used for beacon regions) |
name | String? | Optional display name for the region |
proximityUuid | String? | Optional UUID for proximity beacons |
radius | Int | The radius of the region (in meters for geofences) |
regionType | Int | Numeric type identifier for the region (see Companion constants) |
1fun toJson(): JSONObjectConverts the Region object to its JSON representation.
Returns: JSONObject containing the region data
The Region.Companion object provides constants and factory methods for working with Region instances.
1const val REGION_TYPE_FENCE: Int = 1Constant representing a fence-type region (geofence).
1const val REGION_TYPE_PROXIMITY: Int = 3Constant representing a proximity-type region (beacon).
1@JvmStatic
2fun fromJson(jsonObject: JSONObject?): Region?Creates a Region object from a JSONObject.
Parameters:
jsonObject - A nullable JSONObject containing region dataReturns: A nullable Region instance, or null if creation fails
Annotations: @JvmStatic - Makes this function accessible as a static method from Java
1// Creating a geofence region
2val geofenceRegion = Region(
3 center = LatLon(latitude = 37.7749, longitude = -122.4194),
4 description = "San Francisco Office",
5 id = "sf-office-001",
6 major = 0,
7 messages = emptyList(),
8 minor = 0,
9 name = "SF Office",
10 proximityUuid = null,
11 radius = 100,
12 regionType = Region.REGION_TYPE_FENCE
13)
14
15// Creating a beacon region
16val beaconRegion = Region(
17 center = LatLon(latitude = 37.7749, longitude = -122.4194),
18 description = "Store Entrance Beacon",
19 id = "beacon-001",
20 major = 1,
21 messages = emptyList(),
22 minor = 2,
23 name = "Entrance",
24 proximityUuid = "12345678-1234-1234-1234-123456789012",
25 radius = 0,
26 regionType = Region.REGION_TYPE_PROXIMITY
27)
28
29// Converting to JSON
30val jsonObject = geofenceRegion.toJson()
31
32// Creating from JSON
33val region = Region.fromJson(jsonObject)LatLon - Represents geographic coordinates (latitude/longitude)Message - Represents messages associated with a region