Skip to content

The Official Flutter Plugin for the Marketing Cloud MobilePush SDK.

License

Notifications You must be signed in to change notification settings

salesforce-marketingcloud/sdk-flutter-plugin

Repository files navigation

Salesforce Marketing Cloud Flutter Plugin

This module enables the integration of the Marketing Cloud Engagement MobilePush SDK into your Flutter applications.

Release Notes

For release notes, please refer to CHANGELOG.md.

Requirements

Flutter

  • Flutter version 3.3.0+

iOS

  • minimum deployment target iOS 12+

Android

  • minSdkVersion 21+
  • compileSdkVersion 34+

Installation

To add the plugin to your application via pub, run the following command:

flutter pub add sfmc

Example Implementation

An example implementation is provided within the plugin. For setup details, see the example app.

Android Setup

Please follow detailed step by step guide to setup Android Platform.

iOS Setup

Please follow detailed step by step guide for Swift or Objective-C to setup iOS Platform.

URL Handling

To handle URLs from push notifications, please follow iOS step by step guide for Swift or Objective-C and Android step by step guide.

Please also see additional documentation on URL Handling for Android and iOS.

Using APIs

In your app import the package and utilize the SFMCSdk APIs.

// Import the SFMC package into your application
import 'package:sfmc/sfmc.dart';

// Utilize the APIs
SFMCSdk.getSystemToken();

Please find the API Refrences below.

API Reference

Kind: global class

SFMCSdk.isPushEnabled() ⇒ Future<bool?>

The current state of the pushEnabled flag in the native Marketing Cloud SDK.

Kind: static method of SFMCSdk
Returns: Future<bool?> - A future to the nullable boolean representation of whether push is enabled.
See

SFMCSdk.enablePush() ⇒ Future<void>

Enables push messaging in the native Marketing Cloud SDK.

Kind: static method of SFMCSdk
See

SFMCSdk.disablePush() ⇒ Future<void>

Disables push messaging in the native Marketing Cloud SDK.

Kind: static method of SFMCSdk
See

SFMCSdk.getSystemToken() ⇒ Future<String?>

Returns the token used by the Marketing Cloud to send push messages to the device.

Kind: static method of SFMCSdk
Returns: Future<String?> - A future to the nullable system token string.
See

SFMCSdk.getAttributes() ⇒ Future<Map<String, String>>

Returns the maps of attributes set in the registration.

Kind: static method of SFMCSdk
Returns: Future<Map<String, String>> - A future to the string key/value map of attributes set in the registration.
See

SFMCSdk.setAttribute(key, value) ⇒ Future<void>

Sets the value of an attribute in the registration.

Kind: static method of SFMCSdk
See

Param Type Description
key string The name of the attribute to be set in the registration.
value string The value of the key attribute to be set in the registration.

SFMCSdk.clearAttribute(key) ⇒ Future<void>

Clears the value of an attribute in the registration.

Kind: static method of SFMCSdk
See

Param Type Description
key string The name of the attribute whose value should be cleared from the registration.

SFMCSdk.addTag(tag) ⇒ Future<void>

Adds a tag to the list of tags in the registration.

Kind: static method of SFMCSdk
See

Param Type Description
tag string The tag to be added to the registration.

SFMCSdk.removeTag(tag) ⇒ Future<void>

Removes a tag from the list of tags in the registration.

Kind: static method of SFMCSdk
See

Param Type Description
tag string The tag to be removed from the registration.

SFMCSdk.getTags() ⇒ Future<List<String>>

Returns the list of tags currently set in the registration.

Kind: static method of SFMCSdk
Returns: Future<List<String>> - A future to the list of strings representing the tags currently set in the registration.
See

SFMCSdk.setContactKey(contactKey) ⇒ Future<void>

Sets the contact key for the device's user.

Kind: static method of SFMCSdk
See

Param Type Description
contactKey string The contact key to be set for the device's user.

SFMCSdk.getContactKey() ⇒ Future<String?>

Returns the contact key associated with the device's user.

Kind: static method of SFMCSdk
Returns: Future<String?> - A future to the nullable string representation of the contact key associated with the device's user.
See

SFMCSdk.enableLogging() ⇒ Future<void>

Enables verbose logging within the native Marketing Cloud SDK and Unified SFMC SDK.

Kind: static method of SFMCSdk
See

SFMCSdk.disableLogging() ⇒ Future<void>

Disables verbose logging within the native Marketing Cloud SDK.

Kind: static method of SFMCSdk
See

SFMCSdk.logSdkState() ⇒ Future<void>

Instructs the native SDK to log the SDK state to the native logging system (Logcat for Android and Xcode/Console.app for iOS). This content can help diagnose most issues within the SDK and will be requested by the Marketing Cloud support team.

Kind: static method of SFMCSdk
See

SFMCSdk.trackEvent(event) ⇒ Future<void>

This method helps to track events, which could result in actions such as an InApp Message being displayed.

Kind: static method of SFMCSdk
See

Param Type Description
event CustomEvent | EngagementEvent | SystemEvent | CartEvent | OrderEvent | CatalogObjectEvent The event to be tracked.

SFMCSdk.getDeviceId() ⇒ Future<String?>

Returns the deviceId used by the Marketing Cloud to send push messages to the device.

Kind: static method of SFMCSdk
Returns: Future<String?> - A future to the device Id.
See

SFMCSdk.setAnalyticsEnabled(analyticsEnabled) ⇒ Future<void>

Enables or disables analytics in the Marketing Cloud SDK.

Kind: static method of SFMCSdk
See

Param Type Description
analyticsEnabled boolean A flag indicating whether analytics should be enabled.

SFMCSdk.isAnalyticsEnabled() ⇒ Future<bool>

Checks if analytics is enabled in the Marketing Cloud SDK.

Kind: static method of SFMCSdk
Returns: Future<bool> - A future to the boolean representation of whether analytics is enabled.
See

SFMCSdk.setPiAnalyticsEnabled(analyticsEnabled) ⇒ Future<void>

Enables or disables Predictive Intelligence analytics in the Marketing Cloud SDK.

Kind: static method of SFMCSdk
See

Param Type Description
analyticsEnabled boolean A flag indicating whether PI analytics should be enabled.

SFMCSdk.isPiAnalyticsEnabled() ⇒ Future<bool>

Checks if Predictive Intelligence analytics is enabled in the Marketing Cloud SDK.

Kind: static method of SFMCSdk
Returns: Future<bool> - A future to the boolean representation of whether PI analytics is enabled.
See

SFMCSdk.getMessages() ⇒ Future<List<InboxMessage>>

Returns the list of Active, Read & Unread, not Deleted Inbox Messages.

Kind: static method of SFMCSdk
Returns: Future<List<InboxMessage>> - A future to the InboxMessage list representing Active, Read & Unread, not Deleted Inbox Messages. See

SFMCSdk.getReadMessages() ⇒ Future<List<InboxMessage>>

Returns the list of Active, Read, not Deleted Inbox Messages

Kind: static method of SFMCSdk
Returns: Future<List<InboxMessage>> - A future to the InboxMessage list representing Active, Read, not Deleted Inbox Messages. See

SFMCSdk.getUnreadMessages() ⇒ Future<List<InboxMessage>>

Returns the list of Active, Unread, not Deleted Inbox Messages

Kind: static method of SFMCSdk
Returns: Future<List<InboxMessage>> - A future to the InboxMessage list representing Active, Unread, not Deleted Inbox Messages. See

SFMCSdk.getDeletedMessages() ⇒ Future<List<InboxMessage>>

Returns the list of Active, Deleted Inbox Messages

Kind: static method of SFMCSdk
Returns: Future<List<InboxMessage>> - A future to the InboxMessage list representing Active, Deleted Inbox Messages. See

SFMCSdk.getMessageCount() ⇒ Future<int?>>

Returns the total number of not deleted Inbox Messages

Kind: static method of SFMCSdk
Returns: Future<int?>> - A future to the int representing total number of not deleted Inbox Messages. See

SFMCSdk.getReadMessageCount() ⇒ Future<int?>>

Returns the total number of read, not deleted Inbox Messages

Kind: static method of SFMCSdk
Returns: Future<int?>> - A future to the int representing total number of read, not deleted Inbox Messages. See

SFMCSdk.getUnreadMessageCount() ⇒ Future<int?>>

Returns the total number of unread, not deleted Inbox Messages

Kind: static method of SFMCSdk
Returns: Future<int?>> - A future to the int representing total number of unread, not deleted Inbox Messages. See

SFMCSdk.getDeletedMessageCount() ⇒ Future<int?>>

Returns the total number of deleted Inbox Messages regardless of their read status.

Kind: static method of SFMCSdk
Returns: Future<int?>> - A future to the int representing total number of unread, not deleted Inbox Messages. See

SFMCSdk.setMessageRead(messageId) ⇒ Future<void>

Marks a InboxMessage as read in local storage.

Kind: static method of SFMCSdk
See

Param Type Description
id String The InboxMessage#id() of the InboxMessage to mark as read.

SFMCSdk.deleteMessage(messageId) ⇒ Future<void>

Marks a InboxMessage as deleted in local storage.

Kind: static method of SFMCSdk
See

Param Type Description
id String The InboxMessage#id() of the InboxMessage to mark as deleted.

SFMCSdk.markAllMessagesRead() ⇒ Future<void>>

Marks all active, unread InboxMessages as read.

Kind: static method of SFMCSdk
Returns: Future<void>> - A future to the void that marks all active, unread InboxMessages as read. See

SFMCSdk.markAllMessagesDeleted() ⇒ Future<void>>

Marks all active InboxMessages as deleted.

Kind: static method of SFMCSdk
Returns: Future<void>> - A future to the void that marks all active InboxMessages as deleted. See

SFMCSdk.refreshInbox() ⇒ Future<bool>>

Requests an updated list of Inbox Messages from the Marketing Cloud Servers. The Inbox request can be made, at most, once per minute. This throttle also includes the Inbox request that is made by the SDK when your application is brought into the foreground.

Kind: static method of SFMCSdk
Returns: Future<bool>> - A future to the boolean representation if inbox has been refreshed or not. See

SFMCSdk.registerInboxResponseListener(callback) ⇒ void

Call this method to be notified of Inbox events within the Marketing Cloud SDK.

Kind: static method of SFMCSdk
See

Param Type Description
callback InboxResponseListener The InboxResponseListener that you want to register.

SFMCSdk.unregisterInboxResponseListener(callback) ⇒ void

Unregister your InboxMessageManager.InboxResponseListener listener.

Kind: static method of SFMCSdk
See

Param Type Description
callback InboxResponseListener The InboxResponseListener that you want to unregister.

InboxResponseListener

The InboxResponseListener is a type definition for a callback function that handles a list of InboxMessage objects. It is used to respond to events or actions that return a list of inbox messages.

Kind: typedef

Param Type Description
messages List A list of InboxMessage objects.

InboxRefreshListener

The InboxRefreshListener is a type definition for a callback function that handles the result of an inbox refresh operation. It indicates whether the refresh operation was successful or not.

Kind: typedef

Param Type Description
successful bool A boolean value, indicating the success of the refresh operation. true if the refresh was successful, false otherwise.

parseMessages

The parseMessages function takes a list of JSON strings, each representing an inbox message, and converts it into a list of InboxMessage objects.

Returns: List - A list of InboxMessage objects.

Param Type Description
messages List A list of JSON strings (List), where each string represents the data of an inbox message in JSON format.

3rd Party Product Language Disclaimers

Where possible, we changed noninclusive terms to align with our company value of Equality. We retained noninclusive terms to document a third-party system, but we encourage the developer community to embrace more inclusive language. We can update the term when it’s no longer required for technical accuracy.