Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-native-marketingcloudsdk
Advanced tools
A React Native component to access the native Salesforce Marketing Cloud MobilePush SDKs
Use this module to implement the Marketing Cloud MobilePush SDK for your iOS and Android applications.
Release notes for the plugin can be found here
After updating the dependency from 7.x to 8.x via npm or yarn. Please follow below steps:
SFMCSDK
and MarketingCloudSDK
in AppDelegate
and update the configuration of the SDK as outlined in Step 2 Configure the SDK for iOS.Ensure that you import SFMCSdk
and properly configure the SDK as specified in Step 3 Configure the SDK for Android, which details the process of configuring the SDK for Android in this guide.
npm install react-native-marketingcloudsdk --save
or via yarn
yarn add react-native-marketingcloudsdk
android/build.gradle
allprojects {
repositories {
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
//... Other repos
}
}
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
Include the Google Services plugin in your build
android/build.gradle
buildscript {
repositories {
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.15'
}
}
android/app/build.gradle
// Add the google services plugin to your build.gradle file
apply plugin: 'com.google.gms.google-services'
@Override
public void onCreate() {
super.onCreate();
SFMCSdk.configure((Context) this, SFMCSdkModuleConfig.build(builder -> {
builder.setPushModuleConfig(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));
return null;
}), initializationStatus -> {
Log.e("TAG", "STATUS "+initializationStatus);
if (initializationStatus.getStatus() == 1) {
Log.e("TAG", "STATUS SUCCESS");
}
return null;
});
// ... The rest of the onCreate method
}
// In your App, go to ios directory after installing plugin via npm or yarn.
cd ios
pod install
#import <MarketingCloudSDK/MarketingCloudSDK.h>
#import <SFMCSDK/SFMCSDK.h>
// Other imports ...
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Configure the SFMC sdk
PushConfigBuilder *pushConfigBuilder = [[PushConfigBuilder alloc] initWithAppId:@"{MC_APP_ID}"];
[pushConfigBuilder setAccessToken:@"{MC_ACCESS_TOKEN}"];
[pushConfigBuilder setMarketingCloudServerUrl:[NSURL URLWithString:@"{MC_APP_SERVER_URL}"]];
[pushConfigBuilder setMid:@"MC_MID"];
[pushConfigBuilder setAnalyticsEnabled:YES];
[SFMCSdk initializeSdk:[[[SFMCSdkConfigBuilder new] setPushWithConfig:[pushConfigBuilder build] onCompletion:^(SFMCSdkOperationResult result) {
if (result == SFMCSdkOperationResultSuccess) {
//Enable Push
} else {
// SFMC sdk configuration failed.
NSLog(@"SFMC sdk configuration failed.");
}
}] build]];
// ... The rest of the didFinishLaunchingWithOptions method
}
Follow these instructions to enable push for iOS.
The SDK doesn’t automatically present URLs from these sources.
To handle URLs from push notifications, you'll need to implement the following for Android and iOS.
@Override
public void onCreate() {
super.onCreate();
SFMCSdk.configure((Context) this, SFMCSdkModuleConfig.build(builder -> {
builder.setPushModuleConfig(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)
// Here we set the URL handler to present URLs from CloudPages, OpenDirect, and In-App Messages
.setUrlHandler((context, s, s1) -> PendingIntent.getActivity(
context,
new Random().nextInt(),
new Intent(Intent.ACTION_VIEW, Uri.parse(s)),
PendingIntent.FLAG_UPDATE_CURRENT
)).build(this));
return null;
}), initializationStatus -> {
Log.e("TAG", "STATUS "+initializationStatus);
if (initializationStatus.getStatus() == 1) {
Log.e("TAG", "STATUS SUCCESS");
}
return null;
});
// The rest of the onCreate method
}
// AppDelegate.h ----
#import <MarketingCloudSDK/MarketingCloudSDK.h>
#import <SFMCSDK/SFMCSDK.h>
...
// Implement the SFMCSdkURLHandlingDelegate delegate
@interface AppDelegate : RCTAppDelegate<UNUserNotificationCenterDelegate, SFMCSdkURLHandlingDelegate>
// AppDelegate.mm ----
// This method is called after successfully initializing the SFMCSdk
- (void)pushSetup {
dispatch_async(dispatch_get_main_queue(), ^{
// Here we set the URL Handling delegate to present URLs from CloudPages, OpenDirect, and In-App Messages
[[SFMCSdk mp] setURLHandlingDelegate:self];
// Set UNUserNotificationCenter delegate, register for remote notifications, etc...
});
}
// ...
// Implement the required delegate method to handle URLs
- (void)sfmc_handleURL:(NSURL * _Nonnull)url type:(NSString * _Nonnull)type {
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (success) {
NSLog(@"url %@ opened successfully", url);
} else {
NSLog(@"url %@ could not be opened", url);
}
}];
}
}
Please also see additional documentation on URL Handling for Android and iOS.
Kind: global class
Promise.<boolean>
Promise.<?string>
Promise.<Object.<string, string>>
Promise.<Array.<string>>
Promise.<?string>
Promise.<?string>
Promise.<boolean>
Promise.<boolean>
Promise.<boolean>
The current state of the pushEnabled flag in the native Marketing Cloud SDK.
Kind: static method of MCReactModule
Returns: Promise.<boolean>
- A promise to the boolean representation of whether push is
enabled.
See
Enables push messaging in the native Marketing Cloud SDK.
Kind: static method of MCReactModule
See
Disables push messaging in the native Marketing Cloud SDK.
Kind: static method of MCReactModule
See
Promise.<?string>
Returns the token used by the Marketing Cloud to send push messages to the device.
Kind: static method of MCReactModule
Returns: Promise.<?string>
- A promise to the system token string.
See
Promise.<Object.<string, string>>
Returns the maps of attributes set in the registration.
Kind: static method of MCReactModule
Returns: Promise.<Object.<string, string>>
- A promise to the key/value map of attributes set
in the registration.
See
Sets the value of an attribute in the registration.
Kind: static method of MCReactModule
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. |
Clears the value of an attribute in the registration.
Kind: static method of MCReactModule
See
Param | Type | Description |
---|---|---|
key | string | The name of the attribute whose value should be cleared from the registration. |
Kind: static method of MCReactModule
See
Param | Type | Description |
---|---|---|
tag | string | The tag to be added to the list of tags in the registration. |
Kind: static method of MCReactModule
See
Param | Type | Description |
---|---|---|
tag | string | The tag to be removed from the list of tags in the registration. |
Promise.<Array.<string>>
Returns the tags currently set on the device.
Kind: static method of MCReactModule
Returns: Promise.<Array.<string>>
- A promise to the array of tags currently set in the native SDK.
See
Sets the contact key for the device's user.
Kind: static method of MCReactModule
See
Param | Type | Description |
---|---|---|
contactKey | string | The value to be set as the contact key of the device's user. |
Promise.<?string>
Returns the contact key currently set on the device.
Kind: static method of MCReactModule
Returns: Promise.<?string>
- A promise to the current contact key.
See
Enables verbose logging within the native Marketing Cloud SDK and Unified SFMC SDK.
Kind: static method of MCReactModule
See
Disables verbose logging within the native Marketing Cloud SDK.
Kind: static method of MCReactModule
See
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 MCReactModule
See
This method helps to track events, which could result in actions such as an InApp Message being displayed.
Kind: static method of MCReactModule
See
Param | Type | Description |
---|---|---|
event | CustomEvent | EngagementEvent | IdentityEvent | SystemEvent | CartEvent | OrderEvent | CatalogObjectEvent | The event to be tracked. |
Promise.<?string>
Returns the deviceId used by the Marketing Cloud to send push messages to the device.
Kind: static method of MCReactModule
Returns: Promise.<?string>
- A promise to the device Id.
See
Enables or disables analytics in the Marketing Cloud SDK.
Kind: static method of MCReactModule
See
Param | Type | Description |
---|---|---|
analyticsEnabled | boolean | A flag indicating whether analytics should be enabled. |
Promise.<boolean>
Checks if analytics is enabled in the Marketing Cloud SDK.
Kind: static method of MCReactModule
Returns: Promise.<boolean>
- A promise to the boolean representation of whether analytics is enabled.
See
Enables or disables Predictive Intelligence analytics in the Marketing Cloud SDK.
Kind: static method of MCReactModule
See
Param | Type | Description |
---|---|---|
analyticsEnabled | boolean | A flag indicating whether PI analytics should be enabled. |
Promise.<boolean>
Checks if Predictive Intelligence analytics is enabled in the Marketing Cloud SDK.
Kind: static method of MCReactModule
Returns: Promise.<boolean>
- A promise to the boolean representation of whether PI analytics is enabled.
See
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.
Version 8.1.1
FAQs
A React Native component to access the native Salesforce Marketing Cloud MobilePush SDKs
The npm package react-native-marketingcloudsdk receives a total of 4,370 weekly downloads. As such, react-native-marketingcloudsdk popularity was classified as popular.
We found that react-native-marketingcloudsdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.