IOS
To implement the MarketingCloudSDK framework in your application, either use CocoaPods or manually set up the SDK.
If you are looking to add 8.x version or migrate from older versions to 8.x version, follow Migrating to 8.x guide.
Option 1: Implement the SDK with CocoaPods
Follow the CocoaPods instructions using MarketingCloudSDK as a dependency in the podfile. See CocoaPods - MarketingCloudSDK:
target 'MyApp' do
pod 'MarketingCloudSDK', '~> 7.6'
end
Open the .xcworkspace created by the install process with Xcode and start using the SDK.
Do NOT open .xcodeproj. An error occurs if you open up a project file instead of a workspace.
Option 2: Implement the SDK manually
Copy the MarketingCloudSDK directory from your downloads to your project directory.
Open your application project and select the appropriate target.
Add MarketingCloudSDK.xcframework to Linked Frameworks and Libraries in your target’s General settings.
The below step #5 is needed until MarketingCloudSDK version 8.0.13. Post this version, manual addition of bundle to the application is removed and is automated.
Add MarketingCloudSDK.bundle to Copy Bundle Resources in your target’s Build Phases settings.
Add -ObjC to your target’s Other Linker Flags build settings.
Review additional information from Apple about this linker flag.
Andriod
Create an app in MobilePush. This process connects the device to the MobilePush app you created previously in MobilePush.
The Android SDK requires Android API 21 or greater and has dependencies on the Android Support v4 and Google Play Services libraries.
Add the SDK repository:
repositories {
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
Add the SDK dependency:
dependencies {
implementation 'com.salesforce.marketingcloud:marketingcloudsdk:{currentVersion}'
}
Replace {currentVersion} with 8.1.5 to use the latest SDK version.
The SDK no longer declares the Google Play Services Location or AltBeacon libraries as required dependencies. Follow the instructions for enabling Geofence and Beacon messaging if your application requires these features.
Follow the Android Firebase setup documentation. When you add the Firebase core dependency to your module gradle file, use com.google.firebase:firebase-core:23.x.x.
If you initialize the FirebaseApp manually, you must initialize Firebase before initializing the SDK.
The SDK must be initialized during the execution of your Application class’s onCreate method. Initialization will require configuration data for your Marketing Cloud Application. Please refer to the documentation for guidance on where to find the required pieces of data.
From 8.0.0 onwards, use SFMCSdk to initialize the MarketingCloudSdk.
8.x
7.x
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize logging _before_ initializing the SDK to avoid losing valuable debugging information.
if(BuildConfig.DEBUG) {
SFMCSdk.setLogging(LogLevel.DEBUG, LogListener.AndroidLogger())
MarketingCloudSdk.setLogLevel(MCLogListener.VERBOSE)
MarketingCloudSdk.setLogListener(MCLogListener.AndroidLogListener())
}
SFMCSdk.configure(applicationContext as Application, SFMCSdkModuleConfig.build {
pushModuleConfig = MarketingCloudConfig.builder().apply {
setApplicationId("{mc_application_id}")
setAccessToken("{mc_access_token}")
setSenderId("{fcm_sender_id}")
setMarketingCloudServerUrl("{marketing_cloud_url}")
setNotificationCustomizationOptions(
NotificationCustomizationOptions.create(R.drawable.ic_notification_icon)
)
// Other configuration options
}.build(applicationContext)
}) { initStatus ->
// TODO handle initialization status
}
}
}
If you don’t call the SDK’s configure method and initialize the pushModuleConfig from your app’s onCreate, the SDK can’t post notifications while the app is in the background.
To troubleshoot information the InitializationStatus returned during the SDK’s initialization call, see Initialization Status in the troubleshooting section for more details.
You can customize the display and handling of notifications. See the customize notifications documentation for details.
Android 13 introduces a new runtime permission for showing notifications. This affects all apps running on Android 13 or higher. Your app will not be allowed to show notifications until the user has granted this permission.
See Google’s documentation for details on requesting permissions from the user.
Once the user has accepted the permission to display notifications you will need to notify the SDK:
8.x
SFMCSdk.requestSdk { sdk ->
sdk.mp {
it.pushMessageManager.enablePush()
}
}