Package com.netmera
Class Netmera
java.lang.Object
com.netmera.Netmera
Netmera is the main class to be used for configuring the SDK and interacting with Netmera
servers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanThis method is used to query the Push Notification permissions that come with Android API Level 33.static NotificationPermissionStatuscheckNotificationPermission(android.app.Activity activity) Checks and returns the user's notification permission status.static voidDisable Netmera to present received popups.static voidDisable push notification for this device.static voidDismisses all currently active WebView presentations (popups and other web content activities).static voiddisplayWidget(String url) Display a widget given only its URL, without requiring a push object.static voiddisplayWidget(String url, android.webkit.WebView webView, NetmeraWebViewCallback netmeraWebViewCallback) Display a widget given its URL.static voidEnable Netmera to present received popups immediately.static booleanEnable push notification for this device if system notifications are enabled.static voidenablePush(android.app.Activity activity) Enable push notification for this device if system notifications are enabled.static voidfetchCategory(NetmeraCategoryFilter filter, NetmeraInboxCategory.NetmeraInboxCategoryCallback callback) Fetch the categories of push notifications matching with given filter from Netmera.static voidfetchCoupons(int page, int max, NMFetchCouponsResultListener listener) Returns the coupons according to the parameters given with theNMFetchCouponsResultListener.static voidfetchInbox(NetmeraInboxFilter filter, NetmeraInbox.NetmeraInboxFetchCallback callback) Fetch list of push notifications matching with given filter from Netmera.static voidfetchInboxCount(NetmeraInboxCountFilter filter, NMInboxCountResultListener listener) Returns the number of inbox messages according to the parameters given with theNetmeraInboxCountFilter.static voidfetchPushToken(NMPushTokenResultListener listener) static StringReturns the user's external Id if it has already been set.static voidgetEmailPermission(NMPermissionResultListener listener) Returns the email permission for the userstatic voidgetInboxCountForStatus(NMInboxStatusCountFilter filter, NMInboxCountResultListener listener) Deprecated.static voidgetSmsPermission(NMPermissionResultListener listener) Returns the SMS permission for the userstatic voidFetch the category preference list of a single user.static voidgetUserCategoryPreferenceList(NMCategoryPreferenceFilter filter, NMCategoryPreferenceFetchCallback listener) Fetch the category preference list of a single user, optionally restricted to specific categories and/or channels viaNMCategoryPreferenceFilter.static voidgetWhatsAppPermission(NMPermissionResultListener listener) Returns the WhatsApp permission for the userstatic voidhandleInteractiveAction(android.content.Context context, NetmeraInteractiveAction interactiveAction) Perform push object's interactive actionsstatic voidhandlePushObject(android.app.Activity activity, NetmeraPushObject netmeraPushObject) Perform push object's action or show a simple dialog with action buttons according to push typestatic voidhandleWebContent(android.webkit.WebView webView) Load contents of the web view action of recent push notification in given web view.static voidhandleWebContent(android.webkit.WebView webView, NetmeraWebViewCallback netmeraWebViewCallback) Load contents of the web view action of recent push notification in given web view and delegatesWebViewClient.shouldOverrideUrlLoading(WebView, String)} method calls to given callback.static voidPauses SDK operations without requiring re-initialization.static voididentifyUser(NMUser nmUser) Set or update the identifiers of the user in Netmera.static voididentifyUser(NMUser nmUser, NMUpdateUserListener listener) Deprecated.UseidentifyUser(NMUser, NMIdentifyUserListener)to receive the identify user resultstatic voididentifyUser(NMUser nmUser, NMIdentifyUserListener listener) Set or update the identifiers of the user in Netmera.static voidinit(NetmeraConfiguration netmeraConfiguration) Deprecated.Useinit(NetmeraParams)together with anetmera-config.jsonfile bundled in the host app's assets instead.static voidinit(NetmeraConfiguration netmeraConfiguration, NMInitSessionListener listener) Deprecated.UsesetInitSessionCallback(NMInitSessionResultListener)to receive init session result.static voidinit(NetmeraParams params) Initialize the Netmera instance using a lightweightNetmeraParamsobject, combined with anetmera-config.jsonfile bundled in the host app's assets.static voidDeprecated.This method should not be used, as the crash tracker functionality has been removed from the SDK.static voidinitWithHoldingOperation(NetmeraConfiguration netmeraConfiguration) Deprecated.UseinitWithHoldingOperation(NetmeraParams)together with anetmera-config.jsonfile bundled in the host app's assets instead.static voidinitWithHoldingOperation(NetmeraConfiguration netmeraConfiguration, NMInitSessionListener listener) Deprecated.UseinitWithHoldingOperation(NetmeraConfiguration)combined withsetInitSessionCallback(NMInitSessionResultListener)to receive init session results.static voidinitWithHoldingOperation(NetmeraParams params) This method is for advanced usage; if you think it's required for you, you can contact support@netmera.comstatic booleanisNetmeraRemoteMessage(Object remoteMessage) Deprecated.UseisNetmeraRemoteMessage(Map)for more straightforward way to check the incoming RemoteMessage.static booleanisNetmeraRemoteMessage(Map<String, String> dataOfRemoteMessage) This method should be called for obtaining, if the incoming RemoteMessage is sent from the Netmera Console.static booleanReturnstrueif the SDK is in the OPERATING state — fully initialized, not on hold, and not killed.static booleanCheck push notification state.static voidkill()Kills Netmera completely as if it never exists.static voidDeprecated.This method should not be used, as the crash tracker functionality has been removed from the SDK.static voidonNetmeraNewToken(String token) This method must be called when the application has its own integration of FirebaseMessagingService.static voidonNetmeraNewToken(String token, boolean forceToSend) This method must be called when the application has its own integration of FirebaseMessagingService.static voidonNetmeraPushMessageReceived(Object remoteMessage) This method must be called when the application has its own integration of either FirebaseMessagingService or HmsMessageService.static voidregisterForNetmeraDeeplinkCallback(NMDeeplinkCallback nmDeeplinkCallback) Deprecated.UsesetDeeplinkCallback(NMDeeplinkCallback)instead.static voidregisterForNetmeraInAppmessageActions(NMInAppMessageActionCallbacks nmInAppMessageActionCallbacks) Deprecated.static voidregisterForNetmeraWebWidgetCallbacks(NMWebWidgetCallbacks nmWebWidgetCallbacks) Deprecated.UsesetWebWidgetCallbacks(NMWebWidgetCallbacks)instead.static voidregisterForPushActions(NMPushActionCallbacks nmPushActionCallbacks) Deprecated.UsesetPushActionCallbacks(NMPushActionCallbacks)instead.static voidregisterForPushPresentationCallbacks(NMPushPresentationCallbacks nmPushPresentationCallbacks) Deprecated.static voidregisterProviderComponent(NMProviderComponent nmProviderComponent, NMProviderRegistrationCallback registrationCallback) static voidrequestNotificationPermissions(android.app.Activity activity) This method allows you to get the Push Notification Permissions that come with Android API Level 33 at runtime.static voidrequestNotificationPermissions(android.app.Activity activity, NMPermissionResultListener listener) This method allows you to get the Push Notification Permissions that come with Android API Level 33 at runtime.static voidRequest location permissions from user (For Android version level 23 and above).static voidSend an event to Netmera servers.static <T extends NetmeraEvent>
voidsendEvent(T netmeraEvent) Send an event to Netmera servers.static voidsendScreenErrorEvent(String errorTitle, String errorMessage) static voidSet given Netmera SDK API key.static voidsetBaseUrl(String url) Changes base API URL to given URL string.static voidsetBaseUrlWithApiKey(String baseUrl, String apiKey) Sets given Netmera SDK API key and changes base API URL to given URL string.static voidsetDeeplinkCallback(NMDeeplinkCallback callback) Registers a listener for deeplink open events.static voidsetEmailPermission(boolean isAllowed) Sets the email permission for the userstatic voidRegisters a listener for in-app message action events (shown, opened, dismissed).static voidsetInitSessionCallback(NMInitSessionResultListener listener) Registers a listener that is called on every init session completion, including re-sessions that occur after a session timeout during the app lifecycle, and every background retry the SDK performs after an init session attempt fails.static voidsetLoggingEnabled(boolean enabled) Enables or disables SDK logging.static voidsetNetmeraHeaders(android.content.ContentValues headerValueSet) This method should be called to add custom headers to Netmera Requests for hybrid platforms.static voidsetNetmeraMaxActiveRegions(int netmeraMaxActiveRegions) Request maximum active geofence region from userstatic voidsetPushActionCallbacks(NMPushActionCallbacks callbacks) Registers a listener for push notification action events (open, button click, carousel selection).static voidsetPushPresentationCallbacks(NMPushPresentationCallbacks callbacks) Registers a listener for push/in-app presentation events (e.g.static voidsetSmsPermission(boolean isAllowed) Sets the SMS permission for the userstatic voidsetUserCategoryPreference(int categoryId, Boolean categoryEnabled, NMCategoryPreferenceSetCallback listener) Deprecated.UsesetUserCategoryPreference(NMCategoryPreferenceUpdate, NMCategoryPreferenceSetCallback)instead — migrate by passing the same categoryId and categoryEnabled into aNMCategoryPreferenceUpdate.static voidsetUserCategoryPreference(NMCategoryPreferenceUpdate preference, NMCategoryPreferenceSetCallback listener) Update enable status of user's category preference.static voidsetWebWidgetCallbacks(NMWebWidgetCallbacks callbacks) Registers a listener for web widget events (shown, dismissed, deeplink/url triggered).static voidsetWhatsAppPermission(boolean isAllowed) Sets the WhatsApp permission for the userstatic voidstatic voidEnables event sharing and update user if it has been blocked before.static voidTells Netmera to start working if the SDK is initialized withinitWithHoldingOperation(NetmeraConfiguration)method, or to resume after aholdOperation()call.static voidBlocks event sharing and updating user.static voidtrackComposeAction(String viewIdentifier) Track a Compose action with the given view identifier.static voidtrackComposeView(String viewIdentifier) Track a Compose view with the given view identifier.static voidturnOffSendingEventAndUserUpdate(boolean turnOff) Completely turn off sending all events and user data.static voidupdateAll(int inboxStatus, NetmeraInbox.NetmeraInboxStatusCallback callback) Update status of all push objects in the inbox.static voidupdateStatusByCategories(int inboxStatus, List<String> categoryList, NetmeraInbox.NetmeraInboxStatusCallback callback) Update status of the push objects which are in the given categories.static <T extends NetmeraUser>
voidupdateUser(T netmeraUser) Deprecated.UseidentifyUser(NMUser)for user identification andupdateUserProfile(NMUserProfile)for updating profile attributes.static <T extends NetmeraUser>
voidupdateUser(T netmeraUser, NMUpdateUserListener listener) Deprecated.UseidentifyUser(NMUser)for user identification andupdateUserProfile(NMUserProfile)for updating profile attributes.static <T extends NMUserProfile>
voidupdateUserProfile(T userProfile) Set or update the attributes of the user in Netmera.static <T extends NMUserProfile>
voidupdateUserProfile(T userProfile, NMUpdateUserProfileListener listener) Set or update the attributes of the user in Netmera with a listener for the operation result.
-
Constructor Details
-
Netmera
public Netmera()
-
-
Method Details
-
init
public static void init(@NonNull NetmeraParams params) Initialize the Netmera instance using a lightweightNetmeraParamsobject, combined with anetmera-config.jsonfile bundled in the host app's assets.NetmeraParamscarries the apiKey, providers, and an optional base URL override. SSL pin keys and the Firebase/Huawei sender IDs are not part ofNetmeraParams— they must come fromnetmera-config.json, so that file is mandatory for this entry point; initialization fails (logs an error, does nothing) if it's missing, unreadable, or has no sender ID set. Netmera does not start operating, it even does not exist, unless this method is called. Any Netmera method called before this method is simply ignored. In order for Netmera to operate correctly, this method must definitely be called in theApplication.onCreate()method.- Parameters:
params-NetmeraParamsencapsulates the apiKey, providers, and an optional base URL override.
-
init
Deprecated.Useinit(NetmeraParams)together with anetmera-config.jsonfile bundled in the host app's assets instead. This will be removed in a future release.Initialize the Netmera instance. Netmera does not start operating, it even does not exist, unless this method is called. Any Netmera method called before this method is simply ignored. In order for Netmera to operate correctly, this method must definitely be called in theApplication.onCreate()method.- Parameters:
netmeraConfiguration-NetmeraConfigurationencapsulates all the necessary information for initialization of Netmera instance.
-
init
@Deprecated public static void init(@NonNull NetmeraConfiguration netmeraConfiguration, @Nullable NMInitSessionListener listener) Deprecated.UsesetInitSessionCallback(NMInitSessionResultListener)to receive init session result. The NMInitSessionListener variant will be removed in a future release. -
initWithHoldingOperation
public static void initWithHoldingOperation(@NonNull NetmeraParams params) This method is for advanced usage; if you think it's required for you, you can contact support@netmera.com Initialize the Netmera instance with holding operations tillstartOperation()is called, using a lightweightNetmeraParamsobject combined with anetmera-config.jsonfile bundled in the host app's assets (mandatory — seeinit(NetmeraParams)for details). If SDK is initialized with this method and laterstartOperation()is not called, Netmera will not do anything. Any Netmera method called before this method is simply ignored. In order for Netmera to operate correctly, this method must definitely be called in theApplication.onCreate()method.- Parameters:
params-NetmeraParamsencapsulates the apiKey, providers, and an optional base URL override.
-
initWithHoldingOperation
@Deprecated public static void initWithHoldingOperation(@NonNull NetmeraConfiguration netmeraConfiguration) Deprecated.UseinitWithHoldingOperation(NetmeraParams)together with anetmera-config.jsonfile bundled in the host app's assets instead. This will be removed in a future release.This method is for advanced usage; if you think it's required for you, you can contact support@netmera.com Initialize the Netmera instance with holding operations tillstartOperation()is called. If SDK is initialized with this method and laterstartOperation()is not called, Netmera will not do anything. Any Netmera method called before this method is simply ignored. In order for Netmera to operate correctly, this method must definitely be called in theApplication.onCreate()method.- Parameters:
netmeraConfiguration-NetmeraConfigurationencapsulates all the necessary information for initialization of Netmera instance.
-
initWithHoldingOperation
@Deprecated public static void initWithHoldingOperation(@NonNull NetmeraConfiguration netmeraConfiguration, @Nullable NMInitSessionListener listener) Deprecated.UseinitWithHoldingOperation(NetmeraConfiguration)combined withsetInitSessionCallback(NMInitSessionResultListener)to receive init session results. The NMInitSessionListener variant will be removed in a future release. -
setInitSessionCallback
public static void setInitSessionCallback(@Nullable NMInitSessionResultListener listener) Registers a listener that is called on every init session completion, including re-sessions that occur after a session timeout during the app lifecycle, and every background retry the SDK performs after an init session attempt fails. The listener receives aNetmeraInitSessionResultcontaining the response from the server. It is retained by the SDK and fires again after each new init session and each retry attempt; passnullto release it. Can be called before or afterinit(NetmeraConfiguration).- Parameters:
listener- the listener to register, ornullto remove it
-
startOperation
public static void startOperation()Tells Netmera to start working if the SDK is initialized withinitWithHoldingOperation(NetmeraConfiguration)method, or to resume after aholdOperation()call. If SDK is not in a hold state, this method does nothing. -
holdOperation
public static void holdOperation()Pauses SDK operations without requiring re-initialization. Flushes the active session, then waits for all pending network requests to drain before fully suspending. While suspended, new events are buffered and sent whenstartOperation()is called. Can be called multiple times during the app lifecycle. If the SDK is not in OPERATING state this method is a no-op. -
isOperating
public static boolean isOperating()Returnstrueif the SDK is in the OPERATING state — fully initialized, not on hold, and not killed. -
kill
public static void kill()Kills Netmera completely as if it never exists. If you want Netmera to work again, the SDK should be re-initialized in app launch. -
setBaseUrl
Changes base API URL to given URL string. The only use case for this method is when a custom Netmera domain is defined to your application.- Parameters:
url- Custom domain string.
-
skipAppConfigAndSetBaseUrl
-
setApiKey
Set given Netmera SDK API key. Calling this method with a valid API key will effectively start communication with Netmera servers. Netmera will store any operation until it has an API key Setting API key to null or empty string will stop all network operations, and all pending operations will be stored until a valid API key is set again.- Parameters:
apiKey- Application specific API key gathered from Netmera panel.
-
setBaseUrlWithApiKey
Sets given Netmera SDK API key and changes base API URL to given URL string. Calling this method with a valid API key will effectively start communication with Netmera servers. Netmera will store any operation until it has an API key Setting API key to null or empty string will stop all network operations, and all pending operations will be stored until a valid API key is set again.Please refer to use this method when a custom Netmera domain is defined to your application.
- Parameters:
apiKey- Application specific API key gathered from Netmera panel.
-
turnOffSendingEventAndUserUpdate
public static void turnOffSendingEventAndUserUpdate(boolean turnOff) Completely turn off sending all events and user data. If a true boolean parameter is passed to this method,NetmeraUserupdates andNetmeraEvents will never be sent to server.- Parameters:
turnOff- Flag for opt-out user data and events. Default value is false.
-
startDataTransfer
public static void startDataTransfer()Enables event sharing and update user if it has been blocked before. -
stopDataTransfer
public static void stopDataTransfer()Blocks event sharing and updating user. After this method call startDataTransfer must be called for reactivating. -
sendEvent
public static <T extends NetmeraEvent> void sendEvent(@NonNull T netmeraEvent) Send an event to Netmera servers. You can send behavioral actions of your users using this method. Rather than accepting unstructured information inside events, SDK requires given event to be a valid subclass ofNetmeraEventclass. This approach provides Netmera to verify type of the given event attributes, which is crucial during event analytics operations on Netmera servers.- Parameters:
netmeraEvent- An event object which is subclass ofNetmeraEvent
-
sendEvent
Send an event to Netmera servers. You can send behavioral actions of your users using this method. This method accepts an event code and a map of attributes, which will be wrapped in aNetmeraEventGenericobject internally. This provides a flexible way to send events without requiring a specificNetmeraEventsubclass. However, attributes still need to match the schema defined on the server. For all public event classes, you can use theEVENT_CODEconstant instead of hardcoding the event code string. For example, useNetmeraEventLogin.EVENT_CODEinstead of"n:cl".- Parameters:
code- The event code identifying the type of eventattributes- A map of event attributes (key-value pairs) to be sent with the event
-
trackComposeView
Track a Compose view with the given view identifier. This method is for autotracking only. It tracks when a Compose view is displayed. The givenviewIdentifierwill be prepended with the current page name (activity name and fragment name if available) in the format:"currentPageName|viewIdentifier". The current page name is automatically determined by the SDK based on the current activity and fragment context.- Parameters:
viewIdentifier- The unique identifier for the Compose view
-
trackComposeAction
Track a Compose action with the given view identifier. This method is for autotracking only. It tracks when a user interacts with a Compose component (e.g., button click). The givenviewIdentifierwill be prepended with the current page name (activity name and fragment name if available) in the format:"currentPageName|viewIdentifier". The current page name is automatically determined by the SDK based on the current activity and fragment context.- Parameters:
viewIdentifier- The unique identifier for the Compose action
-
identifyUser
public static void identifyUser(@NonNull NMUser nmUser) Set or update the identifiers of the user in Netmera. In order to update attributes of the user, you should useupdateUserProfile(NMUserProfile)- Parameters:
nmUser-NMUserobject for setting user related identifiers
-
identifyUser
@Deprecated public static void identifyUser(@NonNull NMUser nmUser, @Nullable NMUpdateUserListener listener) Deprecated.UseidentifyUser(NMUser, NMIdentifyUserListener)to receive the identify user resultSet or update the identifiers of the user in Netmera. In order to update attributes of the user, you should useupdateUserProfile(NMUserProfile)- Parameters:
nmUser-NMUserobject for setting user related identifierslistener-NMUpdateUserListenerto receive success or failure callbacks
-
identifyUser
public static void identifyUser(@NonNull NMUser nmUser, @Nullable NMIdentifyUserListener listener) Set or update the identifiers of the user in Netmera. In order to update attributes of the user, you should useupdateUserProfile(NMUserProfile)- Parameters:
nmUser-NMUserobject for setting user related identifierslistener-NMIdentifyUserListenerto receive the identify user result
-
updateUser
Deprecated.UseidentifyUser(NMUser)for user identification andupdateUserProfile(NMUserProfile)for updating profile attributes.Set or update the attributes of the user in Netmera.- Parameters:
netmeraUser-NetmeraUserobject for setting user related attributes
-
updateUser
@Deprecated public static <T extends NetmeraUser> void updateUser(T netmeraUser, NMUpdateUserListener listener) Deprecated.UseidentifyUser(NMUser)for user identification andupdateUserProfile(NMUserProfile)for updating profile attributes.Set or update the attributes of the user in Netmera.- Parameters:
netmeraUser-NetmeraUserobject for setting user related attributeslistener-NMUpdateUserListenerto receive success or failure callbacks
-
updateUserProfile
public static <T extends NMUserProfile> void updateUserProfile(T userProfile) Set or update the attributes of the user in Netmera.- Parameters:
userProfile-NMUserProfileobject for setting user related attributes
-
updateUserProfile
public static <T extends NMUserProfile> void updateUserProfile(T userProfile, NMUpdateUserProfileListener listener) Set or update the attributes of the user in Netmera with a listener for the operation result.- Parameters:
userProfile-NMUserProfileobject containing user-related attributes to be updatedlistener-NMUpdateUserProfileListenerto receive success or failure callbacks
-
enablePush
public static boolean enablePush()Enable push notification for this device if system notifications are enabled. Push notification is enabled by default but if push notification is disabled viadisablePush(), it can be re-enabled via this method. -
enablePush
public static void enablePush(android.app.Activity activity) Enable push notification for this device if system notifications are enabled. Push notification is enabled by default but if push notification is disabled viadisablePush(), it can be re-enabled via this method.- Parameters:
activity-Activityrequest permission if system notifications are disabled below API 33 goes to app settings
-
disablePush
public static void disablePush()Disable push notification for this device. This method can be used to prevent Netmera servers to send push notifications to this device. -
isPushEnabled
public static boolean isPushEnabled()Check push notification state. This method checks both system level state and app level state.- Returns:
- True if both of the states are @code{true}, false otherwise.
-
enablePopupPresentation
public static void enablePopupPresentation()Enable Netmera to present received popups immediately. By default, Netmera does not present received popup style notifications automatically. Use this method to enable Netmera to automatically present popup style notifications if you previously disabled usingdisablePopupPresentation()method. If a popup style notification has been received during the time at which popup presentation was disabled, it will be shown immediately after you call this method. If multiple popup notifications have been received, only the most recent one will be presented. -
disablePopupPresentation
public static void disablePopupPresentation()Disable Netmera to present received popups. By default, Netmera presents received popup style notifications automatically. Use this method to disable Netmera to automatically present popup style notifications. If any popup notification is received during the time at which presentation is disabled, it will be presented immediately after presentation is enabled again viaenablePopupPresentation(). -
dismissAllPresentations
public static void dismissAllPresentations()Dismisses all currently active WebView presentations (popups and other web content activities). This method will close all activeBaseWebViewActivityinstances that are currently displayed, including popup activities and any other web view presentations managed by the SDK. This is useful when you need to programmatically close all Netmera web presentations at once, for example when the user logs out or when you want to clear all active presentations. The method is thread-safe and will ensure that activity finish operations are performed on the main thread. -
handleWebContent
public static void handleWebContent(@NonNull android.webkit.WebView webView) Load contents of the web view action of recent push notification in given web view. When this method is called, Netmera will immediately load the contents of the web view action inside givenWebViewobject. If you need to be notified aboutWebViewClient.shouldOverrideUrlLoading(WebView, String)} method calls, you should usehandleWebContent(WebView, NetmeraWebViewCallback)method.- Parameters:
webView- A WebView instance upon which related HTML content will be loaded.
-
handleWebContent
public static void handleWebContent(@NonNull android.webkit.WebView webView, NetmeraWebViewCallback netmeraWebViewCallback) Load contents of the web view action of recent push notification in given web view and delegatesWebViewClient.shouldOverrideUrlLoading(WebView, String)} method calls to given callback. When this method is called, Netmera will immediately load the contents of the web view action inside givenWebViewobject.- Parameters:
webView- A WebView instance upon which related HTML content will be loaded.netmeraWebViewCallback- A callback instance which will be called for url loadings
-
displayWidget
Display a widget given only its URL, without requiring a push object. When this method is called, Netmera presents the widget itself in its own popup/activity, reusing the same widget-presentation flow used for widget pushes. The same widget URL processing that is applied to widget pushes is applied before loading.- Parameters:
url- The widget URL to display.
-
displayWidget
public static void displayWidget(@NonNull String url, @Nullable android.webkit.WebView webView, @Nullable NetmeraWebViewCallback netmeraWebViewCallback) Display a widget given its URL. When aWebViewis provided, Netmera loads the widget URL into that web view and delegatesWebViewClient.shouldOverrideUrlLoading(WebView, String)} method calls to the given callback, so the host app is responsible for presenting it. When noWebViewis provided, Netmera presents the widget itself in its own popup/activity, reusing the same widget-presentation flow used for widget pushes. In all cases, the same widget URL processing that is applied to widget pushes is applied before loading.- Parameters:
url- The widget URL to display.webView- A WebView instance upon which the widget content will be loaded, ornullto let the SDK present the widget.netmeraWebViewCallback- A callback instance which will be called for url loadings.
-
handlePushObject
public static void handlePushObject(@NonNull android.app.Activity activity, @NonNull NetmeraPushObject netmeraPushObject) Perform push object's action or show a simple dialog with action buttons according to push type When this method is called, if push object has action buttons, a simple dialog with buttons will be shown. If one of button is clicked by user, its action will be taken. If push object has no action buttons, the action related to object itself will be taken directly.- Parameters:
activity- The activity in which dialog will be shown.netmeraPushObject- Push object instance to process
-
fetchInbox
public static void fetchInbox(@NonNull NetmeraInboxFilter filter, @NonNull NetmeraInbox.NetmeraInboxFetchCallback callback) Fetch list of push notifications matching with given filter from Netmera. This method will start the fetch process and return immediately. When fetch process is finished, given callback will be called with aNetmeraInboxobject or with a non-nullNetmeraErrorobject if fetch operation has failed. Use returned NetmeraInbox object for future operations on the inbox such as accessing the objects, fetching next pages of the inbox list, and modifying the status of objects.- Parameters:
filter- ANetmeraInboxFilterobject defining the filter options for the list of push objects to be returned from server.callback- ANetmeraInbox.NetmeraInboxFetchCallbackto be triggered after fetch process is completed.- See Also:
-
fetchCategory
public static void fetchCategory(@NonNull NetmeraCategoryFilter filter, @NonNull NetmeraInboxCategory.NetmeraInboxCategoryCallback callback) Fetch the categories of push notifications matching with given filter from Netmera. This method will start the fetch process and return immediately. When fetch process is finished, given callback will be called with aNetmeraCategoryobject or with a non-nullNetmeraErrorobject if fetch operation has failed. Use returned NetmeraInboxCategory object for future operations on the category such as accessing the objects or fetching next pages of the category list.- Parameters:
filter- ANetmeraCategoryFilterobject defining the filter options for the list of categories to be returned from server.callback- ANetmeraInboxCategory.NetmeraInboxCategoryCallbackto be triggered after fetch process is completed.- See Also:
-
requestPermissionsForLocation
public static void requestPermissionsForLocation()Request location permissions from user (For Android version level 23 and above). Calling this method will trigger OS to present location permission dialog to user. After permissions are granted, location tracking and geofence monitoring will start if they have been configured on Netmera panel. You do not need to call this method if your app already has Location permission. -
requestNotificationPermissions
public static void requestNotificationPermissions(android.app.Activity activity) This method allows you to get the Push Notification Permissions that come with Android API Level 33 at runtime.- Parameters:
activity- Necessary for context
-
requestNotificationPermissions
public static void requestNotificationPermissions(android.app.Activity activity, @Nullable NMPermissionResultListener listener) This method allows you to get the Push Notification Permissions that come with Android API Level 33 at runtime.- Parameters:
activity- Necessary for contextlistener-NMPermissionResultListenerto receive result: onSuccess(true) when granted, onSuccess(false) when denied, onFailure on error
-
checkNotificationPermission
public static NotificationPermissionStatus checkNotificationPermission(android.app.Activity activity) Checks and returns the user's notification permission status.- Parameters:
activity- Necessary for context- Returns:
NotificationPermissionStatusenum representing the current permission status.
-
areNotificationsEnabled
public static boolean areNotificationsEnabled()This method is used to query the Push Notification permissions that come with Android API Level 33.- Returns:
- Always returns true if the application has Build.VERSION.SDK_INT < 33 or if the user grants the necessary permissions. Otherwise false
-
setNetmeraMaxActiveRegions
public static void setNetmeraMaxActiveRegions(int netmeraMaxActiveRegions) Request maximum active geofence region from user If user sets max active regions' number greater than 100 or smaller than 0, it will be set as the default which is 100- Parameters:
netmeraMaxActiveRegions- Maximum Netmera active geofence regions
-
onNetmeraPushMessageReceived
This method must be called when the application has its own integration of either FirebaseMessagingService or HmsMessageService. Please consider calling this when application's onMessageReceived(Object remoteMessage) method was triggered by either Firebase Console or Huawei Console.- Parameters:
remoteMessage- com.google.firebase.messaging.RemoteMessage or com.huawei.hms.push.RemoteMessage Push notification message, which was caught by either FirebaseMessagingService or HmsMessageService
-
onNetmeraNewToken
This method must be called when the application has its own integration of FirebaseMessagingService. Please consider calling this when application's onNewToken(String s) method was triggered by Firebase or HMS.- Parameters:
token- Token, which was caught by depending on provider.
-
onNetmeraNewToken
This method must be called when the application has its own integration of FirebaseMessagingService. Please consider calling this when application's onNewToken(String s) method was triggered by Firebase or HMS.- Parameters:
token- Token, which was caught by depending on provider.forceToSend- Force to send new token to the server.
-
fetchPushToken
-
isNetmeraRemoteMessage
Deprecated.UseisNetmeraRemoteMessage(Map)for more straightforward way to check the incoming RemoteMessage.- Parameters:
remoteMessage- Push notification message, which was sent by FCM or HMS
-
isNetmeraRemoteMessage
This method should be called for obtaining, if the incoming RemoteMessage is sent from the Netmera Console. True - If RemoteMessage belongs Netmera Console False - For other sources- Parameters:
dataOfRemoteMessage- Push notification message, which was sent by FCM or HMS, If called from FCM service pass remoteMessage.data, If called from HMS service pass remoteMessage.dataOfMap.
-
setNetmeraHeaders
public static void setNetmeraHeaders(android.content.ContentValues headerValueSet) This method should be called to add custom headers to Netmera Requests for hybrid platforms. Usage of this method is not obligatory. Unlike most other setters, safe to call right afterinit(NetmeraParams), even while it's still initializing on its background thread - the header value is only read lazily when a request is actually sent.- Parameters:
headerValueSet- - Header Map, which holds key-value pairs
-
updateAll
Update status of all push objects in the inbox. Calling this method will update the inbox status of all push objects, and result will be informed via givenNetmeraInbox.NetmeraInboxStatusCallbackobject. Anullerrorvalue means operation succeeded. Setting multiple status options to status parameter will result in an immediate error.- Parameters:
inboxStatus- Status option to be set upon given push objects.callback- ANetmeraInbox.NetmeraInboxStatusCallbackto be triggered after update process is completed.
-
updateStatusByCategories
public static void updateStatusByCategories(int inboxStatus, @NonNull List<String> categoryList, NetmeraInbox.NetmeraInboxStatusCallback callback) Update status of the push objects which are in the given categories. Calling this method will update the inbox status of push objects which are in the given categories, and result will be informed via givenNetmeraInbox.NetmeraInboxStatusCallbackobject. Anullerrorvalue means operation succeeded. Setting multiple status options to status parameter will result in an immediate error.- Parameters:
inboxStatus- Status option to be set upon to all push objects which are in the given categories.categoryList- The list of categories whose push objects will be updated.callback- ANetmeraInbox.NetmeraInboxStatusCallbackto be triggered after update process is completed.
-
handleInteractiveAction
public static void handleInteractiveAction(@NonNull android.content.Context context, @NonNull NetmeraInteractiveAction interactiveAction) Perform push object's interactive actions When this method is called, action according to push object's interactive action will be triggered/shown. (For example triggering of a deeplink or showing webpage upon button click.)- Parameters:
context- Activity context will be accepted.interactiveAction- Push object'sNetmeraInteractiveAction.
-
getCurrentExternalId
Returns the user's external Id if it has already been set.- Returns:
- String external id of the user
-
setUserCategoryPreference
@Deprecated public static void setUserCategoryPreference(int categoryId, Boolean categoryEnabled, NMCategoryPreferenceSetCallback listener) Deprecated.UsesetUserCategoryPreference(NMCategoryPreferenceUpdate, NMCategoryPreferenceSetCallback)instead — migrate by passing the same categoryId and categoryEnabled into aNMCategoryPreferenceUpdate. -
setUserCategoryPreference
public static void setUserCategoryPreference(@NonNull NMCategoryPreferenceUpdate preference, NMCategoryPreferenceSetCallback listener) Update enable status of user's category preference.- Parameters:
preference-NMCategoryPreferenceUpdatecarrying the category id and enabled status to update; itsNMCategoryChannelscopes the update to a single channel, ornullto update the global preference.listener-NMCategoryPreferenceSetCallbackNeeded for listening network results.
-
getInboxCountForStatus
@Deprecated public static void getInboxCountForStatus(NMInboxStatusCountFilter filter, @NonNull NMInboxCountResultListener listener) Deprecated.NMInboxStatusCountFilter#categoryListis incorrectly typed asArray<Integer>, but the backend expects category names as strings. UsefetchInboxCount(NetmeraInboxCountFilter, NMInboxCountResultListener)instead.Returns the number of inbox messages according to the parameters given with theNMInboxStatusCountFilter.- Parameters:
filter-NMInboxStatusCountFilterlistener-NMInboxCountResultListenerNeeded for listening network results.
-
fetchInboxCount
public static void fetchInboxCount(NetmeraInboxCountFilter filter, @NonNull NMInboxCountResultListener listener) Returns the number of inbox messages according to the parameters given with theNetmeraInboxCountFilter.- Parameters:
filter-NetmeraInboxCountFilterlistener-NMInboxCountResultListenerNeeded for listening network results.
-
fetchCoupons
public static void fetchCoupons(int page, int max, @NonNull NMFetchCouponsResultListener listener) Returns the coupons according to the parameters given with theNMFetchCouponsResultListener.- Parameters:
page- the page number [0...Max_Int]max- maximum count [1...Max_Int]
-
getUserCategoryPreferenceList
public static void getUserCategoryPreferenceList(@NonNull NMCategoryPreferenceFetchCallback listener) Fetch the category preference list of a single user.- Parameters:
listener-NMCategoryPreferenceFetchCallbackNeeded for listening network results.NMCategoryPreferencelist will be returned onSuccess method callback.
-
getUserCategoryPreferenceList
public static void getUserCategoryPreferenceList(@NonNull NMCategoryPreferenceFilter filter, @NonNull NMCategoryPreferenceFetchCallback listener) Fetch the category preference list of a single user, optionally restricted to specific categories and/or channels viaNMCategoryPreferenceFilter. A category that supports none of the requested channels is omitted from the result entirely. Regardless of the filter's channels, each returned preference's enabled status keeps reporting the backward-compatible aggregate:trueif the category is enabled on any of its own channels.- Parameters:
filter-NMCategoryPreferenceFilterto restrict the result by category id and/or channel.listener-NMCategoryPreferenceFetchCallbackNeeded for listening network results.NMCategoryPreferencelist will be returned onSuccess method callback.
-
initCrashTracker
Deprecated.This method should not be used, as the crash tracker functionality has been removed from the SDK. -
logException
Deprecated.This method should not be used, as the crash tracker functionality has been removed from the SDK. -
setLoggingEnabled
public static void setLoggingEnabled(boolean enabled) Enables or disables SDK logging. Required when using theinit(NetmeraParams)entry point, since neitherNetmeraParamsnornetmera-config.jsoncarry a logging flag. Can be called before or afterinit(NetmeraParams). Note that the deprecatedinit(NetmeraConfiguration)path unconditionally appliesNetmeraConfiguration.Builder#logging(boolean)on init, overwriting whatever was set here if this was called first.- Parameters:
enabled- whether SDK logging should be enabled
-
setPushActionCallbacks
Registers a listener for push notification action events (open, button click, carousel selection). Can be called before or afterinit(NetmeraConfiguration).- Parameters:
callbacks- the callbacks to register, ornullto remove them
-
setInAppMessageActionCallbacks
public static void setInAppMessageActionCallbacks(@Nullable NMInAppMessageActionCallbacks callbacks) Registers a listener for in-app message action events (shown, opened, dismissed). Can be called before or afterinit(NetmeraConfiguration).- Parameters:
callbacks- the callbacks to register, ornullto remove them
-
setWebWidgetCallbacks
Registers a listener for web widget events (shown, dismissed, deeplink/url triggered). Can be called before or afterinit(NetmeraConfiguration).- Parameters:
callbacks- the callbacks to register, ornullto remove them
-
setPushPresentationCallbacks
public static void setPushPresentationCallbacks(@Nullable NMPushPresentationCallbacks callbacks) Registers a listener for push/in-app presentation events (e.g. custom web view presentation). Can be called before or afterinit(NetmeraConfiguration).- Parameters:
callbacks- the callbacks to register, ornullto remove them
-
setDeeplinkCallback
public static void setDeeplinkCallback(@Nullable NMDeeplinkCallback callback) Registers a listener for deeplink open events. Can be called before or afterinit(NetmeraConfiguration).- Parameters:
callback- the callback to register, ornullto remove it
-
registerForPushActions
Deprecated.UsesetPushActionCallbacks(NMPushActionCallbacks)instead. -
registerForNetmeraInAppmessageActions
@Deprecated public static void registerForNetmeraInAppmessageActions(NMInAppMessageActionCallbacks nmInAppMessageActionCallbacks) Deprecated. -
registerForNetmeraWebWidgetCallbacks
@Deprecated public static void registerForNetmeraWebWidgetCallbacks(NMWebWidgetCallbacks nmWebWidgetCallbacks) Deprecated.UsesetWebWidgetCallbacks(NMWebWidgetCallbacks)instead. -
registerForPushPresentationCallbacks
@Deprecated public static void registerForPushPresentationCallbacks(NMPushPresentationCallbacks nmPushPresentationCallbacks) Deprecated. -
registerForNetmeraDeeplinkCallback
@Deprecated public static void registerForNetmeraDeeplinkCallback(NMDeeplinkCallback nmDeeplinkCallback) Deprecated.UsesetDeeplinkCallback(NMDeeplinkCallback)instead. -
sendScreenErrorEvent
-
registerProviderComponent
public static void registerProviderComponent(NMProviderComponent nmProviderComponent, NMProviderRegistrationCallback registrationCallback) -
setEmailPermission
public static void setEmailPermission(boolean isAllowed) Sets the email permission for the user- Parameters:
isAllowed- permission to be set
-
getEmailPermission
public static void getEmailPermission(@NonNull NMPermissionResultListener listener) Returns the email permission for the user- Parameters:
listener-NMPermissionResultListenerto receive success or failure callbacks
-
setSmsPermission
public static void setSmsPermission(boolean isAllowed) Sets the SMS permission for the user- Parameters:
isAllowed- permission to be set
-
getSmsPermission
public static void getSmsPermission(@NonNull NMPermissionResultListener listener) Returns the SMS permission for the user- Parameters:
listener-NMPermissionResultListenerto receive success or failure callbacks
-
setWhatsAppPermission
public static void setWhatsAppPermission(boolean isAllowed) Sets the WhatsApp permission for the user- Parameters:
isAllowed- permission to be set
-
getWhatsAppPermission
public static void getWhatsAppPermission(@NonNull NMPermissionResultListener listener) Returns the WhatsApp permission for the user- Parameters:
listener-NMPermissionResultListenerto receive success or failure callbacks
-
NMInboxStatusCountFilter#categoryListis incorrectly typed asArray<Integer>, but the backend expects category names as strings.