A React Native component to access the native Salesforce Marketing Cloud MobilePush SDKs
npm install react-native-marketingcloudsdk-taqtileUse this module to implement the Marketing Cloud MobilePush SDK for your iOS and Android applications.
Release notes for the plugin can be found here
* Plugin has a version dependency on React Native v0.60+
#### 1. Add plugin to your application via npm
``shell`
npm install react-native-marketingcloudsdk --save
#### 1. Add Marketing Cloud SDK repository
android/build.gradle`groovy`
allprojects {
repositories {
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
//... Other repos
}
}
#### 2. Provide FCM credentials
1. To enable push support for the Android platform you will need to include the google-services.json file. Download the file from your Firebase console and place it into the android/app directory
2. Include the Google Services plugin in your build
android/build.gradle`groovy
buildscript {
repositories {
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.2.0'
}
}
`android/app/build.gradle
3. Apply the plugin`groovy`
// Add the following line to the bottom of the file:
apply plugin: 'com.google.gms.google-services
#### 3. Configure the SDK in your MainApplication.java class
`java
@Override
public void onCreate() {
super.onCreate();
MarketingCloudSdk.init(this,
MarketingCloudConfig.builder()
.setApplicationId("{MC_APP_ID}")
.setAccessToken("{MC_ACCESS_TOKEN}")
.setSenderId("{FCM_SENDER_ID_FOR_MC_APP}")
.setMarketingCloudServerUrl("{MC_APP_SERVER_URL}")
.setNotificationCustomizationOptions(NotificationCustomizationOptions.create(R.drawable.ic_notification))
.setAnalyticsEnabled(true)
.build(this),
initializationStatus -> Log.e("INIT", initializationStatus.toString()));
// ... The rest of the onCreate method
}
`
#### 1. Install pod for Marketing Cloud SDK
`shell`
cd ios
pod install
#### 2. Configure the SDK in your AppDelegate.m class
`objc
// Add this import at the top (before #if RCT_NEW_ARCH_ENABLED)
#import
// Other imports ...
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MarketingCloudSDKConfigBuilder *mcsdkBuilder = [MarketingCloudSDKConfigBuilder new];
[mcsdkBuilder sfmc_setApplicationId:@"{MC_APP_ID}"];
[mcsdkBuilder sfmc_setAccessToken:@"{MC_ACCESS_TOKEN}"];
[mcsdkBuilder sfmc_setAnalyticsEnabled:@(YES)];
[mcsdkBuilder sfmc_setMarketingCloudServerUrl:@"{MC_APP_SERVER_URL}"];
NSError *error = nil;
BOOL success =
[[MarketingCloudSDK sharedInstance] sfmc_configureWithDictionary:[mcsdkBuilder sfmc_build]
error:&error];
// ... The rest of the didFinishLaunchingWithOptions method
}
`
#### 3. Enable Push
Follow these instructions to enable push for iOS.
Kind: global class
* MCReactModule
* .isPushEnabled() ⇒ Promise.<boolean>
* .enablePush()
* .disablePush()
* .getSystemToken() ⇒ Promise.<?string>
* .getAttributes() ⇒ Promise.<Object.<string, string>>
* .setAttribute(key, value)
* .clearAttribute(key)
* .addTag(tag)
* .removeTag(tag)
* .getTags() ⇒ Promise.<Array.<string>>
* .setContactKey(contactKey)
* .getContactKey() ⇒ Promise.<?string>
* .enableVerboseLogging()
* .disableVerboseLogging()
* .logSdkState()
* .track()
Kind: static method of MCReactModule
Returns: Promise.<boolean> - A promise to the boolean representation of whether push is
enabled.
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
Returns: Promise.<?string> - A promise to the system token string.
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
Returns: Promise.<Object.<string, string>> - A promise to the key/value map of attributes set
in the registration.
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
See
- Android Docs)
- iOS Docs
| 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. |
Kind: static method of MCReactModule
See
- Android Docs)
- iOS Docs
| Param | Type | Description |
| --- | --- | --- |
| key | string | The name of the attribute whose value should be cleared from the registration. |
MCReactModule - Android Docs)
- iOS Docs
| Param | Type | Description |
| --- | --- | --- |
| tag | string | The tag to be added to the list of tags in the registration. |
MCReactModule - Android Docs)
- iOS Docs
| Param | Type | Description |
| --- | --- | --- |
| tag | string | The tag to be removed from the list of tags in the registration. |
Kind: static method of MCReactModule
Returns: Promise.<Array.<string>> - A promise to the array of tags currently set in the native SDK.
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
See
- Android Docs)
- iOS Docs
| Param | Type | Description |
| --- | --- | --- |
| contactKey | string | The value to be set as the contact key of the device's user. |
Kind: static method of MCReactModule
Returns: Promise.<?string> - A promise to the current contact key.
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
See
- Android Docs)
- iOS Docs
Kind: static method of MCReactModule
Kind: static method of MCReactModule