Class Marigold
-
- All Implemented Interfaces:
public final class Marigold
Keeps track of necessary environment variables provided by the developer or google. Also provides the entry point into Marigold for the developer to retrieve device information.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
Marigold.MarigoldHandler
Generic handler for async calls to the Marigold SDK.
-
Field Summary
Fields Modifier and Type Field Description public final static String
ACTION_NOTIFICATION_TAPPED
public final static String
ACTION_NOTIFICATION_ACTION_TAPPED
public final static String
ACTION_MESSAGE_COUNT_UPDATE
public final static String
ACTION_MESSAGE_READ
public final static Integer
DEFAULT_NOTIFICATION_PERMISSION_REQUEST_CODE
-
Constructor Summary
Constructors Constructor Description Marigold()
-
Method Summary
Modifier and Type Method Description final Unit
setNotificationConfig(NotificationConfig notificationConfig)
Sets the configuration of notifications built by Marigold. final Unit
addNotificationReceivedListener(NotificationReceivedListener listener)
Adds listener to be called when a notification is received. final Unit
addNotificationTappedListener(NotificationTappedListener listener)
Adds listener to be called when a notification is tapped. final Unit
addNotificationActionTappedListener(NotificationActionTappedListener listener)
Adds listener to be called when a notification action is tapped. final Unit
setInAppNotificationsEnabled(Boolean enabled)
Enables or disables the display of In-App Notifications. final Unit
startEngine(Context context, String appKey)
Initialises The Marigold Mobile SDK. final Unit
updateLocation(Location location)
Updates Marigold with this device's location. final Unit
setGeoIpTrackingEnabled(Boolean enabledGeoIp, Marigold.MarigoldHandler<Void> handler)
Enabled location tracking based on IP Address. final Unit
setGeoIpTrackingEnabled(Boolean enabledGeoIp)
Enabled location tracking based on IP Address. final Unit
setGeoIpTrackingDefault(Boolean enabledGeoIp)
Set whether location tracking based on IP Address will be enabled or disabled by default when a device is created. final Unit
logRegistrationEvent(String userId)
Log a registration event with Marigold. final Unit
getDeviceId(Marigold.MarigoldHandler<String> handler)
Gets this devices ID on the Marigold Mobile Platform. final Unit
setLogger(Logger logger)
All logging within Marigold Mobile is routed through this Logger. final Unit
setDeviceToken(String token)
Pass the FCM token into the Marigold Mobile SDK. final Unit
handleNotification(RemoteMessage remoteMessage)
Pass received notification to Marigold Mobile SDK. final Unit
syncNotificationSettings()
Checks the notifications enabled setting for the app and updates the device on the Marigold Mobile platform if required. final NotificationPermissionRequestResult
requestNotificationPermission(Activity activity, Boolean isRationaleActivity, Integer requestCode)
Handles the flow for requesting the android.Manifest.permission.POST_NOTIFICATIONS permission required for push notifications from Android 13(T)+. final NotificationPermissionRequestResult
requestNotificationPermission(Activity activity, Boolean isRationaleActivity)
Handles the flow for requesting the android.Manifest.permission.POST_NOTIFICATIONS permission required for push notifications from Android 13(T)+. final NotificationPermissionRequestResult
requestNotificationPermission(Activity activity)
Handles the flow for requesting the android.Manifest.permission.POST_NOTIFICATIONS permission required for push notifications from Android 13(T)+. -
-
Method Detail
-
setNotificationConfig
final Unit setNotificationConfig(NotificationConfig notificationConfig)
Sets the configuration of notifications built by Marigold.
- Parameters:
notificationConfig
- The notification configuration to use
-
addNotificationReceivedListener
final Unit addNotificationReceivedListener(NotificationReceivedListener listener)
Adds listener to be called when a notification is received. This method should be called after startEngine
- Parameters:
listener
- your implementation of NotificationReceivedListener
-
addNotificationTappedListener
final Unit addNotificationTappedListener(NotificationTappedListener listener)
Adds listener to be called when a notification is tapped. This method should be called after startEngine
- Parameters:
listener
- your implementation of NotificationTappedListener
-
addNotificationActionTappedListener
final Unit addNotificationActionTappedListener(NotificationActionTappedListener listener)
Adds listener to be called when a notification action is tapped. This method should be called after startEngine
- Parameters:
listener
- your implementation of NotificationActionTappedListener
-
setInAppNotificationsEnabled
final Unit setInAppNotificationsEnabled(Boolean enabled)
Enables or disables the display of In-App Notifications. Must be called before startEngine. In-App Notifications are enabled by default.
- Parameters:
enabled
-false
to disable In-App Notifications andtrue
to re-enable.
-
startEngine
final Unit startEngine(Context context, String appKey)
Initialises The Marigold Mobile SDK. See documentation Connecting to Marigold Mobile for usage.
- Parameters:
context
- Application ContextappKey
- The App Key of your application on the Marigold Mobile platform.
-
updateLocation
final Unit updateLocation(Location location)
Updates Marigold with this device's location.
- Parameters:
location
- new location update
-
setGeoIpTrackingEnabled
@JvmOverloads() final Unit setGeoIpTrackingEnabled(Boolean enabledGeoIp, Marigold.MarigoldHandler<Void> handler)
Enabled location tracking based on IP Address. Tracking location tracking is enabled by default. Use this method for users who may not want to have their location tracked at all.
- Parameters:
enabledGeoIp
- A boolean value indicating whether or not to disable location based on IP Address.handler
- Handler for the result of enabling/disabling geo IP tracking.
-
setGeoIpTrackingEnabled
@JvmOverloads() final Unit setGeoIpTrackingEnabled(Boolean enabledGeoIp)
Enabled location tracking based on IP Address. Tracking location tracking is enabled by default. Use this method for users who may not want to have their location tracked at all.
- Parameters:
enabledGeoIp
- A boolean value indicating whether or not to disable location based on IP Address.
-
setGeoIpTrackingDefault
final Unit setGeoIpTrackingDefault(Boolean enabledGeoIp)
Set whether location tracking based on IP Address will be enabled or disabled by default when a device is created. This method must be called before startEngine.
- Parameters:
enabledGeoIp
- A boolean value indicating whether or not location based on IP Address should be enabled by default.
-
logRegistrationEvent
final Unit logRegistrationEvent(String userId)
Log a registration event with Marigold. This is used to log users signing in and out of the app. Pass the ID you wish to use for the sign-in or null for a sign-out.
- Parameters:
userId
- The ID of the user signing in, or null for sign-out.
-
getDeviceId
final Unit getDeviceId(Marigold.MarigoldHandler<String> handler)
Gets this devices ID on the Marigold Mobile Platform.
- Parameters:
handler
- Callback returns this devices ID
-
setLogger
final Unit setLogger(Logger logger)
All logging within Marigold Mobile is routed through this Logger.
- Parameters:
logger
- a custom logger implementation.
-
setDeviceToken
final Unit setDeviceToken(String token)
Pass the FCM token into the Marigold Mobile SDK. NOTE: This method should only be called if the app implements its own FirebaseMessagingService instance, in which case it must be called in order to provide the FCM token to the Marigold Mobile Platform. Otherwise this will be handled automatically by the Marigold Mobile SDK.
- Parameters:
token
- FCM token provided by FirebaseMessagingService
-
handleNotification
final Unit handleNotification(RemoteMessage remoteMessage)
Pass received notification to Marigold Mobile SDK. NOTE: This method should only be called if the app implements its own FirebaseMessagingService instance, in which case it must be called in order to provide FCM notifications to the Marigold Mobile SDK for processing. Otherwise this will be handled automatically by the Marigold Mobile SDK.
- Parameters:
remoteMessage
- FCM notification
-
syncNotificationSettings
final Unit syncNotificationSettings()
Checks the notifications enabled setting for the app and updates the device on the Marigold Mobile platform if required. From Android 13(T)+ it is recommended that this be called in when the result of the android.Manifest.permission.POST_NOTIFICATIONS permission is received to ensure the platform has the correct setting.
-
requestNotificationPermission
@JvmOverloads() final NotificationPermissionRequestResult requestNotificationPermission(Activity activity, Boolean isRationaleActivity, Integer requestCode)
Handles the flow for requesting the android.Manifest.permission.POST_NOTIFICATIONS permission required for push notifications from Android 13(T)+. This is a no-op on earlier Android versions and will return NotificationPermissionRequestResult.PERMISSION_NOT_REQUIRED.
- Parameters:
activity
- The activity to use to make the permissions request.isRationaleActivity
- Boolean representing whether the activity provides details to the user justifying the need for the notifications permission.requestCode
- The request code used to track the permissions request.
-
requestNotificationPermission
@JvmOverloads() final NotificationPermissionRequestResult requestNotificationPermission(Activity activity, Boolean isRationaleActivity)
Handles the flow for requesting the android.Manifest.permission.POST_NOTIFICATIONS permission required for push notifications from Android 13(T)+. This is a no-op on earlier Android versions and will return NotificationPermissionRequestResult.PERMISSION_NOT_REQUIRED.
- Parameters:
activity
- The activity to use to make the permissions request.isRationaleActivity
- Boolean representing whether the activity provides details to the user justifying the need for the notifications permission.
-
requestNotificationPermission
@JvmOverloads() final NotificationPermissionRequestResult requestNotificationPermission(Activity activity)
Handles the flow for requesting the android.Manifest.permission.POST_NOTIFICATIONS permission required for push notifications from Android 13(T)+. This is a no-op on earlier Android versions and will return NotificationPermissionRequestResult.PERMISSION_NOT_REQUIRED.
- Parameters:
activity
- The activity to use to make the permissions request.
-
-
-
-