Skip to content

Instantly share code, notes, and snippets.

View sfmc-mobilepushsdk's full-sized avatar

Salesforce Marketing Cloud Mobile Push SDK sfmc-mobilepushsdk

View GitHub Profile
@sfmc-mobilepushsdk
sfmc-mobilepushsdk / ShouldShowInAppMessage.kt
Created March 12, 2024 04:22
An example showcasing the process of deferring in-app messages and revealing them at desired moments.
override fun shouldShowMessage(message: InAppMessage): Boolean {
val deferredId = sharedPreferences.getString("DeferredMessageId", null)
var showMessage = sharedPreferences.getBoolean("shouldShowIam", true)
showMessage = deferredId.let {
showMessage || it == message.id
}
Log.d(TAG, "returned = $showMessage for shouldShowMessage(message: id[${message.id}])")
if(!showMessage){
// store the message ID in a list/preferences that were deferred
@sfmc-mobilepushsdk
sfmc-mobilepushsdk / BuMigrater.md
Last active February 8, 2023 17:14
The intent of this gist is to demonstrate how you can migrate a consumers registration from one BU to another.

The intent of this gist is to demonstrate how you can migrate a consumers registration from one BU to another.

  1. Get an instance of the SDK
  2. Gather the data you wish to transfer
  3. Register a Registration Listener
  4. Disable Push (opt the device out)
  5. Re-init the SDK with the new BU credentials
  6. Set the values you previously gathered
@sfmc-mobilepushsdk
sfmc-mobilepushsdk / index.js
Created March 17, 2020 13:09
Enable Marketing Cloud MobilePush InApp Message CTA handling in your Cordova application.
var pushEnabled = false;
var app = {
onDeviceReady: function() {
// Other actions as required by your app
MCCordovaPlugin.setOnUrlActionListener(app.urlActionListener);
},
urlActionListener: function(value) {
var jsonString = JSON.stringify(value, null, 4);
document.getElementById('urlActionData').textContent = jsonString;
// configure the JB4A SDK in your AppDelegate.m
#import "AppDelegate.h"
#import "ETPush.h"
// AppCenter AppIDs and Access Tokens for the debug and production versions of your app
// These values should be stored securely by your application or retrieved from a remote server
static NSString *kETAppID_Debug = @"change_this_to_your_debug_appId"; // uses Sandbox APNS for debug builds
static NSString *kETAccessToken_Debug = @"change_this_to_your_debug_accessToken";
BOOL successful = NO;
NSError *error = nil;
// configure and set initial settings of the JB4ASDK
successful = [[ETPush pushManager] configureSDKWithAppID:kETAppID_Debug
andAccessToken:kETAccessToken_Debug
withAnalytics:YES
andLocationServices:YES
andProximityServices:YES
andCloudPages:YES
withPIAnalytics:YES
//Listener for kDidDisplayLocationMessageNotification EventBus
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
[center addObserverForName:kDidDisplayLocationMessageNotification object:nil
queue:mainQueue usingBlock:^(NSNotification *notification) {
ETEventMessage *message = notification.object;
if (message)
{
NSLog(@"Message messageName: %@",message.messageName);