GithubHelp home page GithubHelp logo

allboatsrise / expo-marketingcloudsdk Goto Github PK

View Code? Open in Web Editor NEW
9.0 6.0 8.0 711 KB

Expo module for Salesforce Marketing Cloud SDK

License: MIT License

JavaScript 0.26% TypeScript 26.07% Ruby 1.51% Objective-C 0.36% Kotlin 39.71% Swift 32.10%

expo-marketingcloudsdk's Introduction

@allboatsrise/expo-marketingcloudsdk

This is an Expo module that provides a wrapper around the Salesforce Marketing Cloud SDK for iOS and Android.

It allows Expo-based apps to integrate with the Marketing Cloud SDK.

Installation

To install the package use your preferred package manager:

npm install @allboatsrise/expo-marketingcloudsdk expo-notifications zod

or

yarn add @allboatsrise/expo-marketingcloudsdk expo-notifications zod

Plugin setup

Add package to plugins in app.js/app.config.js with minimal configuration.

"expo": {
  "plugins": [
    [
      "@allboatsrise/expo-marketingcloudsdk", {
        "appId": "<< MARKETING_CLOUD_APP_ID >>",
        "accessToken": "<< MARKETING_CLOUD_ACCESS_TOKEN >>",
        "serverUrl": "<< MARKETING_CLOUD_SERVER_URL >>",
      }
    ],
    "expo-notifications"
    ]
}

Sample initialization of notifications in the app

import * as Notifications from 'expo-notifications'
import * as MarketingCloud from '@allboatsrise/expo-marketingcloudsdk'

// ensure push notifications appear regardless whether app is active or not
Notifications.setNotificationHandler({
  handleNotification: async (_notification) => {
    return {
      shouldShowAlert: true,
      shouldPlaySound: true,
      shouldSetBadge: true,
    }
  },
})

export const App: React.FC = () => {
  useEffect(() => {
    let cleanup = () => {}

    ;(async () => {
      // request push notifications permission on load
      // ideally: show this elsewhere where it's more relevant instead of as soon as when the ap loads
      let result = await Notifications.getPermissionsAsync()
      if (!result.granted && result.canAskAgain) {
        result = await Notifications.requestPermissionsAsync({
          ios: {
            allowAlert: true,
            allowBadge: true,
            allowSound: true,
          },
        })
      }

      if (!result.granted) return

      const token = await Notifications.getDevicePushTokenAsync()

      // let Marketing Cloud SDK the value of current push token
      MarketingCloud.setSystemToken(token.data)

      // In rare situations a push token may be changed by the push notification service while the app is running.
      const subscription = Notifications.addPushTokenListener((newToken) => {
        MarketingCloud.setSystemToken(newToken.data)
      })
      cleanup = () => subscription.remove()
    })()

    return () => cleanup()
  }, [])

  // remaining app logic...
}

Plugin parameters

Parameter Type Required Description
appId string Yes Marketing Cloud app id
accessToken string Yes Marketing Cloud access token
serverUrl string Yes Marketing Cloud server url
senderId (Android only) string No Marketing Cloud FCM sender id. Defaults to project_info.project_number defined in android.googleServicesFile (google-services.json) if defined.
mid string No Sets the configuration value to use for the Salesforce MarketingCloud Tenant Specific mid.
inboxEnabled boolean No Sets the configuration flag that enables or disables inbox services
locationEnabled boolean No Sets the configuration flag that enables or disables location services
analyticsEnabled boolean No Sets the configuration flag that enables or disables Salesforce MarketingCloud Analytics services
applicationControlsBadging boolean No Sets the configuration value which enables or disables application control over badging
delayRegistrationUntilContactKeyIsSet boolean No Sets the configuration value which enables or disables application control over delaying SDK registration until a contact key is set
markNotificationReadOnInboxNotificationOpen boolean No Sets the configuration value which enables or disables marking inbox notifications as read on open
debug boolean No Enable logging debug messages

Usage

Various functions, their parameters, return values, and their specific purposes in ExpoMarketingCloudSdk

Functions

Function Name Parameters Return Type Description
isPushEnabled None Promise<boolean> Returns a promise that resolves to a boolean indicating whether push notifications are enabled for the user.
enablePush None Promise<void> Returns a promise that resolves when push notifications have been successfully enabled.
disablePush None Promise<void> Returns a promise that resolves when push notifications have been successfully disabled.
getSystemToken None Promise<string> Returns a promise that resolves to a string representing the device's push notification token.
setSystemToken token: string Promise<void> Returns a promise that resolves when the device's push notification token has been successfully set.
getAttributes None Promise<Record<string, string>> Returns a promise that resolves to an object representing the user's attributes.
setAttribute key: string, value: string Promise<void> Returns a promise that resolves when an attribute has been successfully set for the user.
clearAttribute key: string Promise<void> Returns a promise that resolves when an attribute has been successfully cleared for the user.
addTag tag: string Promise<void> Returns a promise that resolves when a tag has been successfully added for the user.
removeTag tag: string Promise<void> Returns a promise that resolves when a tag has been successfully removed for the user.
getTags None Promise<string[]> Returns a promise that resolves to an array of strings representing the user's tags.
setContactKey contactKey: string Promise<void> Returns a promise that resolves when the user's contact key has been successfully set.
getContactKey None Promise<string> Returns a promise that resolves to a string representing the user's contact key.
getSdkState None Promise<Record<string, unknown>> Returns a promise that resolves to an object representing the current state of the SDK.
track name: string, attributes: Record<string, string> Promise<void> Returns a promise that resolves when a custom event has been successfully tracked.
deleteMessage messageId: string Promise<void> Returns a promise that resolves when a specific inbox message has been successfully deleted.
getDeletedMessageCount None Promise<number> Returns a promise that resolves to a number representing the total number of deleted inbox messages.
getDeletedMessages None Promise<InboxMessage[]> Returns a promise that resolves to an array of InboxMessage objects representing the deleted inbox messages.
getMessageCount None Promise<number> Returns a promise that resolves to a number representing the total number of inbox messages.
getMessages None Promise<InboxMessage[]> Returns a promise that resolves to an array of InboxMessage objects representing the inbox messages.
getReadMessageCount None Promise<number> Returns a promise that resolves to a number representing the total number of read inbox messages.
getReadMessages None Promise<InboxMessage[]> Returns a promise that resolves to an array of InboxMessage objects representing the read inbox messages.
trackMessageOpened messageId: string Promise Returns a promise that resolves to true when inbox open event successfully triggered on message.

Add event listener

Available event listeners:

Function Parameters Description
addLogListener listener: (event: LogEventPayload) => void Adds a listener function to the onLog event, which is triggered when a new log event is generated.
addInboxResponseListener listener: (event: InboxResponsePayload) => void Adds a listener function to the onInboxResponse event, which is triggered when a new inbox response is received.
addRegistrationResponseSucceededListener listener: (event: RegistrationResponseSucceededPayload) => void Adds a listener function to the onRegistrationResponseSucceeded event, which is triggered when SDK successfully registers with backend.
// listeners being used in a useEffect hook.

useEffect(() => {
    const logSubscription = addLogListener((logEvent: LogEventPayload) => {
        // Do something with logEvent
      })

    const inboxSubscription = addInboxResponseListener((inboxEvent: InboxResponsePayload) => {
        // Do something with inboxEvent
      })

    const registrationSubscription = MarketingCloud.addRegistrationResponseSucceededListener((registrationEvent: RegistrationResponseSucceededPayload) => {
      // Do something with registrationEvent
    })

    return () => {
      logSubscription.remove()
      inboxSubscription.remove()
      registrationSubscription.remove()
    }
}, [])

expo-marketingcloudsdk's People

Contributors

andrejpavlovic avatar eridr avatar felipegcastro avatar

Stargazers

 avatar Daisuke Masuhara avatar  avatar Aljaž Kosirnik - Specto avatar Maarten Busstra avatar Devansh Agarwal avatar Ion Korol avatar Max Mönch avatar  avatar

Watchers

James Cloos avatar  avatar  avatar Daisuke Masuhara avatar  avatar  avatar

expo-marketingcloudsdk's Issues

Impossible to run app in Expo GO

Hi, I'm try to integrate this package in my project.

I follow the instruction in README file, but I'm getting this error message
Error: Cannot find native module 'ExpoMarketingCloudSdk', js engine: hermes
image

Here the installed packages
image

Here a piece of code that throws the error, specifically at MarketingCloud.setSystemToken (the very first call to MarketingCloud utilities)
`; (async () => {

    ...

    const token = await Notifications.getDevicePushTokenAsync()
    // let Marketing Cloud SDK the value of current push token
    try{
      MarketingCloud.setSystemToken(token.data)
        .then(response => {
          setStatus(response ?? "null response from MC")
        })

      // In rare situations a push token may be changed by the push notification service while the app is running.
      const subscription = Notifications.addPushTokenListener((newToken) => {
        MarketingCloud.setSystemToken(newToken.data)
      })
      cleanup = () => subscription.remove()
    }
    catch(e: any){
      setStatus(e.message)
    }
  })()

`
The error is thrown only on Expo Go, when I build the app (via eas) for internal distribution all seems to work well.

Thank you

Unable to install `expo-marketingcloudsdk` package

Hi !
Thank you very much for putting up this helpful package.
I am currently trying to use Marketing Cloud MobilePush in an expo project, but I get a 404 NPM Registry Error when I try to install expo-marketingcloudsdk package.

Issue description

NPM 404 Error when trying to install expo-marketingcloudsdk package as per the current documentation

To Reproduce

run yarn add expo-marketingcloudsdk or npm install expo-marketingcloudsdk --save

Screenshots/Code

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/expo-marketingcloudsdk - Not found
npm ERR! 404 
npm ERR! 404  'expo-marketingcloudsdk@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Thank you in advance for your help !

Example of how to use the plugin

Hello. Could you show a simple example to use the plugin?
I'm using expo 48 and the plugin version "^48.0.4". When I import (import * as MarketingCloud from '@allboatsrise/expo-marketingcloudsdk'), this error returns: "Error: Cannot find native module 'ExpoMarketingCloudSdk', js engine: hermes".

Thank you very much

Receiving empty push notification on Android

Hi, I integrated this package in my project and everything works well on iOS devices, but on Android I'm encountering some problems

The os correctly receive the push notifications and shows previews with title/text and image (if set), but when the user taps on it and opens the app the notification request seems to be empty, here and example printed via console.log

{ "notification": { "request": { "trigger": { "channelId": null, "type": "push" }, "content": { "title": null, "dataString": null, "body": null }, "identifier": null }, "date": 0 }, "actionIdentifier": "expo.modules.notifications.actions.DEFAULT" }

For debugging purpose I also send push notification via Expo Push Notification Tool https://expo.dev/notifications and it works well either on iOS and Android devices, so the issue seems to be related to MC package, here an example of received notification from expo tool

{ "notification": { "request": { "trigger": { "remoteMessage": { "originalPriority": 2, "sentTime": 1722597307339, "notification": { "usesDefaultVibrateSettings": false, "color": null, "channelId": null, "visibility": null, "sound": null, "tag": null, "bodyLocalizationArgs": null, "imageUrl": null, "title": "title", "vibrateTimings": null, "ticker": null, "eventTime": null, "body": "text android", "titleLocalizationKey": null, "notificationPriority": null, "icon": null, "usesDefaultLightSettings": false, "sticky": false, "link": null, "titleLocalizationArgs": null, "bodyLocalizationKey": null, "usesDefaultSound": false, "clickAction": null, "localOnly": false, "lightSettings": null, "notificationCount": null }, "data": { "message": "text android", "title": "title", "body": "{}", "scopeKey": "****************", "experienceId": "****************", "projectId": "****************" }, "to": null, "ttl": 0, "collapseKey": "****************", "messageType": null, "priority": 2, "from": "****************", "messageId": "****************" }, "channelId": null, "type": "push" }, "content": { "title": "title", "badge": null, "autoDismiss": true, "data": {}, "body": "text android", "sound": "default", "sticky": false, "subtitle": null }, "identifier": "****************" }, "date": 1722597307339 }, "actionIdentifier": "expo.modules.notifications.actions.DEFAULT" }

the the push notification is logged from the notification response received listener

Notifications.addNotificationResponseReceivedListener(async (response) => { console.log(JSON.stringify(response)) ...

Does anyone have any ideas?

Xcode build fail with error

Hi @andrejpavlovic !
I am unable to build the App using Xcode after installing @allboatsrise/expo-marketingcloudsdk

Expected Behavior

Xcode build success

Actual Behavior

Xcode build throws error after running npx expo prebuild -p ios:
'EXNotifications/EXNotificationCenterDelegate.h' file not found in Pods > Development Pods > ExpoMarketingCloudSdk > ExpoMarketingCloudSdk-Bridging-Header.h

Steps to Reproduce the Problem

  1. run npx expo prebuild -p ios
  2. open project in Xcode > run Build command

Specifications

  • Dependencies:
    • "expo": "~48.0.15",
    • "expo-notifications": "~0.18.1",
    • "@allboatsrise/expo-marketingcloudsdk": "^48.0.0",
    • "react-native": "0.71.7",
  • Platform: IOS
  • Xcode Version 14.3

Thank you in advance for your help !

Enable building with useFrameworks: "static" for iOS devices

Hi @andrejpavlovic !

Thank you for maintaining this module. I have a question regarding building this plugin with useFrameworks: "static" set for iOS devices (added with the expo-build-properties). I need to add it in order to enable React Native Firebase in my project. I'm not really sure what that would require from the package to support building from the "framework" instead of the static library.

app.config.ts:

      [
        "expo-build-properties",
        {
          ios: {
            useFrameworks: "static",
          },
        },
      ],

Error message during run fastlane step in the eas build:

image

Thank you in advance for your help!

No messages received

Hi all, I'm currently trying to get push notifications working. So far I've managed to get push notifications on iOS and android devices 🥳 However we would like to open a certain screen inside of the app using the OpenDirect method (https://help.salesforce.com/s/articleView?id=sf.mc_mp_opendirect.htm&type=5) However I don't get any message or event inside the app, tried adding listeners all over the place, querying for inbox messages, but nothing showed up.
I do however work with an expo development build, could that be impacting the message delivery?

We are currently still on v48.0.4. I'd be happy for any ideas or hints.

Build issue

We are encountering an issue related to Gradle while attempting to build."

Running 'gradlew :app:bundleRelease' in /home/expo/workingdir/build/android
Downloading https://services.gradle.org/distributions/gradle-7.5.1-all.zip
10
%.
20%.
30
%.
40%.
50%.
60%
70%.
80%.
90%.
100%
Welcome to Gradle 7.5.1!
Here are the highlights of this release:

Task :react-native-gradle-plugin:pluginDescriptors
Task :react-native-gradle-plugin:processResources
Task :react-native-gradle-plugin:compileKotlin
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (10, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (119, 30): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (135, 26): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (157, 32): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (163, 31): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (171, 36): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt: (114, 48): 'reactRoot: DirectoryProperty' is deprecated. reactRoot was confusing and has been replace with root to point to your root project and reactNativeDir to point to the folder of the react-native NPM package
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (10, 37): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (11, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (12, 37): 'LibraryVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (27, 51): 'BaseVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (130, 12): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (131, 12): 'LibraryVariant' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (251, 14): 'BaseVariant' is deprecated. Deprecated in Java
Task :react-native-gradle-plugin:compileJava NO-SOURCE
Task :react-native-gradle-plugin:classes
Task :react-native-gradle-plugin:inspectClassesForKotlinIC
Task :react-native-gradle-plugin:jar
FAILURE: Build failed with an exception.

  • Where:
    Build file '/home/expo/workingdir/build/android/build.gradle' line: 41
  • What went wrong:
    A problem occurred evaluating project ':allboatsrise-expo-marketingcloudsdk'.

Failed to apply plugin class 'org.gradle.api.plugins.BasePlugin'.
No signature of method: org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.maven() is applicable for argument types: (build_a4pmw2504rhdm3lg68kv7pbd1$_run_closure1$_closure2$_closure4) values: [build_a4pmw2504rhdm3lg68kv7pbd1$_run_closure1$_closure2$_closure4@6506dde9]
Possible solutions: min(), max(), take(int), max(java.util.Comparator), min(java.util.Comparator), max(groovy.lang.Closure)

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

  • Get more help at
    https://help.gradle.org
    BUILD FAILED in 1m 34s
    5 actionable tasks: 5 executed
    Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

ExpoMarketingCloudSdk

hey, i get Error: Cannot find native module 'ExpoMarketingCloudSdk', js engine: hermes when i try to open app with prebuild.

I follow step on README, but i dont know why i got this error

in my app.config.js
[
'@allboatsrise/expo-marketingcloudsdk',
{
appId: '...',
accessToken: '....',
serverUrl:
'....',
},
],
'expo-notifications',
],

expo version: 50.0.17
allboatsrise/expo-marketingcloudsdk": "^50.2.1"

Failed to convert token to data type

Hi & thank you for creating this library!
I have been trying to solve this issue for a couple of days now, and I can't figure out the solution. When calling

MarketingCloud.setSystemToken(token.data);

this gets executed from the library:

    AsyncFunction("setSystemToken") { (token: String, promise: Promise) in
      do {
        let token = try ExpoMarketingCloudSdkDeviceToken.init(hexString: token)

        SFMCSdk.requestPushSdk { mp in
          mp.setDeviceToken(token.data)
          promise.resolve(mp.deviceToken())
        }
      } catch {
        promise.reject("invalid-hex-token", "Failed to convert token to data type")
      }
    }

and I got back the error Failed to convert token to data type.

I have checked multiple things:

  • appId, accessToken & serverUrl all get included in the EAS build and are the same on the Salesforce dashboard
  • the expo notification token works
  • MarketingCloud.isPushEnabled() returns true
  • addLogListener returns nothing specific that would indicate an issue
  • I have used the boilerplate code from the README example of the library

Do you happen to know what the issue would be?

Example of how to use allboatsrise / expo-marketingcloudsdk

Copied from private message

I tried to use it in my project, but unfortunately without success. Could you share with me a working example of the project that uses this plugin for receiving push notifications via salesforce? From my site, I can offer to create the PR to update the README of the plugin with a description of how to use it in the app. Problems that I'm facing:

  • The newest version of the plugin (46.4.1) is not compatible with the newest sdk version (7.5.2)
    I have fixed that by changing the versions to "46.3.0" for the plugin and "7.5.1" for the SDK.

  • After fixing the version my device was visible in the salesforce contacts (so it was a small success) but unfortunately with the status "not opted in" (it seems that the enablePush changed nothing)

I also thought that maybe I should use only a plugin without the SDK but after running the development build on my iPhone I receive the error: ""main" has not been registered", so I guess I will need it.

addInboxResponseListener not working

Hi, I'm trying to retrieve the payload of a received push, but the addInboxResponseListener listener doesn't work, it simply doesn't log any information when the push is received

inboxEnabled is set to true

Android build error

After the upgrade to version 50.1.0 I am seeing this build error building on EAS Build. Am I missing something?

Execution failed for task ':allboatsrise-expo-marketingcloudsdk:compileDebugKotlin'.

> 'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.

  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

image

iOS push notifications not working

Hey guys,

Need some help.

I installed the package and added the plugin to expo config.

I am getting notifications on android but not on iOS.

Any idea?

iOS issues

I am stuck with this issue, SF support doesn't seem to know also, so I am looking for help here if anyone will know.

Android works and all the devices and contacts get set inside Marketing Cloud, but on iOS no promises resolve, it fails on the first function call.

Versions:

		"@allboatsrise/expo-marketingcloudsdk": "^50.2.0",
		"expo": "~50.0.17",
		"expo-notifications": "~0.27.7",

App config:

               // .........
		[
			'@allboatsrise/expo-marketingcloudsdk',
			{
				appId: envData.marketingcloudsdk.appId,
				accessToken: envData.marketingcloudsdk.accessToken,
				serverUrl: envData.marketingcloudsdk.serverUrl,
				mid: envData.marketingcloudsdk.mid,
				inboxEnabled: true,
				applicationControlsBadging: true,
				markNotificationReadOnInboxNotificationOpen: true,
				delayRegistrationUntilContactKeyIsSet: true,
			} as MarketingCloudSdkPluginProps,
		],
		'expo-notifications',
               // .........

How I am testing it:

const [isDone, setIsDone] = useState(false);
	const [logs, setLogs] = useState<string[]>([]);

	useEffect(() => {
		let cleanup = () => {};

		(async () => {
			let result = await Notifications.getPermissionsAsync();
			if (!result.granted && result.canAskAgain) {
				result = await Notifications.requestPermissionsAsync({
					ios: {
						allowAlert: true,
						allowBadge: true,
						allowSound: true,
					},
				});
			}

			if (!result.granted) {
				return;
			}

			const token = await Notifications.getDevicePushTokenAsync();

			// let Marketing Cloud SDK the value of current push token
			await MarketingCloud.setSystemToken(token.data);
			setIsDone(true);

			// In rare situations a push token may be changed by the push notification service while the app is running.
			const subscription = Notifications.addPushTokenListener((newToken) => {
				MarketingCloud.setSystemToken(newToken.data);
			});
			cleanup = () => subscription.remove();
		})();

		return () => cleanup();
	}, []);

	useEffect(() => {
		const logSubscription = addLogListener((logEvent: LogEventPayload) => {
			setLogs((prevLogs) => [...prevLogs, `Log event: ${logEvent.message}`]);
		});

		const inboxSubscription = addInboxResponseListener((inboxEvent: InboxResponsePayload) => {
			setLogs((prevLogs) => [...prevLogs, `Inbox event: ${inboxEvent.messages}`]);
		});

		const registrationSubscription = addRegistrationResponseSucceededListener(
			(registrationEvent: RegistrationResponseSucceededPayload) => {
				setLogs((prevLogs) => [...prevLogs, `Registration event: ${registrationEvent}`]);
			},
		);

		return () => {
			logSubscription.remove();
			inboxSubscription.remove();
			registrationSubscription.remove();
		};
	}, []);

Logs:

 LOG  Log event: {"category": "sfmcsdk", "level": 0, "message": "The module is not operational yet. Status: failed. This task will be queued.", "subsystem": "SFMCSdk"}
 LOG  Log event: {"category": "sfmcsdk", "level": 0, "message": "The module is not operational yet. Status: failed. This task will be queued.", "subsystem": "SFMCSdk"}
 LOG  Log event: {"category": "sfmcsdk", "level": 0, "message": "The module is not operational yet. Status: failed. This task will be queued.", "subsystem": "SFMCSdk"}

So it never goes over setSystemToken, the push token is valid, the promise never finishes. There is also no error when wrapping with try catch.

What I have also tried:

  1. Adding ContactKey before setStystemToken():
				await MarketingCloud.setContactKey(contactId);
				await MarketingCloud.setSystemToken(notificationToken);
				await MarketingCloud.enablePush();
  1. Removing additional stuff from app.config, like mid, inboxEnabled, applicationControlsBadging,..

Does anyone know where the issue might be? Why would the SDK fail on iOS, while Android works fine?

Push notifications not showing on Android with the app closed

Hello folks!

I'm not really sure if this is related to this library or expo-notifications itself but I'm having a hard time making it work on Android when the app is closed.

The push notification is delivered on SFMC, the device is registered, and I can see it right away after opening the app but for some reason, it doesn't show when the app is closed.

I was looking into the AndroidManifest.xml file for this plugin but everything looks correct to me.

I'm currently on SDK48, does anyone have any idea on what could be causing it?

Really appreciate it!

"MismatchSenderId" for Android platform when sending push notifications

Hello everyone,

We are currently facing an issue with sending push notifications to Android devices. In the push extract, we encounter a "SenderId mismatch" error with a status of "Fail". This issue affects 90% of our Android devices, while the remaining 10% receive notifications successfully.

We have verified that the project_number in our google-services.json matches the SenderId in the Firebase Console. Additionally, we have updated the Service Account JSON file in the Administration panel (Marketing Cloud), but the issue persists.

When conducting tests via the Administration panel (Test Configuration), we receive a Service Status of "Forbidden" and a Failure Type of "MismatchSenderId" within the Push Job section. All sections "turn green" except Send Status which displays a message "Push Not Sent".

Salesforce support answer: "Open a support case, but I can tell you this is easily fixed by reconciling all the pieces of data: The projectId (aka senderId) you've configured in your SDK is NOT from the same project from which you have provided your JSON authorization file to the server. That is the ONLY thing that returns the error you're receiving."

This kind of indicated that the problem might be in the SDK initialization process. I am looking at the Multiple Push SDKs problem. We are only using expo-notification and @allboatsrise/expo-marketingcloudsdk.

Since this is an unofficial Salesforce plugin there is no additional support offered. Did anyone had this problem with their implementation?

Any insights or suggestions to resolve this issue would be greatly appreciated.

Marketing Cloud SDK not tracking user interactions on push notifications

Hello !

I am using Marketing Cloud Mobile Push for push notification to send push notifications to registered devices and having some trouble tracking "Opened" and "Last activity date".

Screenshot 2023-07-11 at 15 45 15

I tried the @allboatsrise/expo-marketingcloudsdk .track() method, but it doesn't seem to work.

On MC SDK documentation they provide some information about tracking and I wanted to know if that has been implemented in this package.

Does anyone have the same issue ?
Any idea why did is happening ?

Thank you !

Expo version 50

Hi everybody.

Has anybody tried the latest 49.1.0 version here with ExpoV50? We tried a bit today, but it seems to have some problems at least when building android. It complains about different java targets (11 instead of 17).
Anybody having look making it to work with Android already?

Build error "Could not set unknown property 'debuggableVariants' for extension 'react' of type com.facebook.react.ReactExtension" when using the library

Hello,

I'm having issues with the Android build process. After installing the library it works well on iOS (after following the fixes mentioned in issue 6 but it's breaking the Android build with the following error:

> Configure project :allboatsrise-expo-marketingcloudsdk
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :app
 ℹ️  Applying gradle plugin 'expo-dev-launcher-gradle-plugin' ([email protected])

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/yyyyy/Projects/xxxx-app/android/app/build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not set unknown property 'debuggableVariants' for extension 'react' of type com.facebook.react.ReactExtension.

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

I've tested without the library and the app builds correctly, so something here conflicts with the app gradle config. I've also posted on a similar issue in the expo repo and they (correctly) pointed me out to the library itself.

For reference I'm using the latest library version 48.0.0 and the latest expo 48.0.17.

Any idea what might be happening? thank you!

iOS: Module is not initialized. You need to initialize before using. Current status: failed

Hi @andrejpavlovic !

Thank you for maintaining this module. Last time we talked in April, you helped me to set up the notifications for both Android and iOS. We had some problems with the Android notifications so we were focused on that. Unfortunately, yesterday we realized that the iOS notifications are no longer working for us.

It seems that the Salesforce module is not initialized in our app. Should we do anything else than:

    const devicePushToken = await Notifications.getDevicePushTokenAsync();
    await MarketingCloud.enablePush();
    await MarketingCloud.setSystemToken(devicePushToken.data);

Of course before this code we take care about providing the permissions for the notifications.

Expected Behavior

The module is initialized on iOS, so we can register the device in Salesforce and set and fetch data like contactKey or attributes.

Actual Behavior

After enabling the log listener I receive this message to the console:
{"category": "interface", "level": 0, "message": "Module is not initialized. You need to initialize before using. Current status: failed", "subsystem": "SFMCSdk"}
Worth to mention that the same code works for Android without the problem.
Are you familiar with this error? Do you know what may cause this issue only for iOS devices? Should we initialize the module from our code, or it should be initialized automatically? Any help would be appreciated.

Specifications

package.json:

    "@allboatsrise/expo-marketingcloudsdk": "48.0.0",
    "@expo/config-plugins": "~6.0.0",
    "expo": "^48.0.6",
    "expo-notifications": "~0.18.1",

app.config.ts:

      [
        "@allboatsrise/expo-marketingcloudsdk",
        {
          appId: process.env.SALESFORCE_APP_ID ?? easTestEnv.SALESFORCE_APP_ID,
          accessToken: process.env.SALESFORCE_ACCESS_TOKEN ?? easTestEnv.SALESFORCE_ACCESS_TOKEN,
          serverUrl: process.env.SALESFORCE_SERVER_URL ?? easTestEnv.SALESFORCE_SERVER_URL,
          mid: "<MID>",
          senderId: "<SENDER_ID>",
          analyticsEnabled: false,
          applicationControlsBadging: false,
          inboxEnabled: true,
          locationEnabled: false,
          iconFile: path.join(__dirname, "assets", "images", "notification-icon.png"),
        } as MarketingCloudSdkPluginProps,
      ],
      "expo-notifications",

(removed the value from mid and senderId)
For now, pasting only related packages, if needed I can provide more.

Thank you in advance for your help!

Android build fails with Expo 48 when this plugin is included

expo-marketingcloudsdk: 48.0.3
expo: 48.0.0

iOS builds successfully.

Both worked fine with Expo 47.

App builds for both platforms if this plugin and its app.config block are removed.

app.config:

[
    "@allboatsrise/expo-marketingcloudsdk",
    {
        appId: process.env.MC_APP_ID,
        accessToken: process.env.MC_ACCESS_TOKEN,
        serverUrl: process.env.MC_APP_SERVER_URL,
    },
],

Log of gradlew from EAS build:

Running 'gradlew :app:assembleDebug' in /home/expo/workingdir/build/android
Downloading https://services.gradle.org/distributions/gradle-7.5.1-all.zip
10%
20%.
30%.
40%.
50%.
60
%.
70%
80%
90%
100%
Welcome to Gradle 7.5.1!
Here are the highlights of this release:
 - Support for Java 18
 - Support for building with Groovy 4
 - Much more responsive continuous builds
 - Improved diagnostics for dependency resolution
For more details see https://docs.gradle.org/7.5.1/release-notes.html
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.5.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
> Task :react-native-gradle-plugin:pluginDescriptors
> Task :react-native-gradle-plugin:processResources
> Task :expo-dev-launcher-gradle-plugin:pluginDescriptors
> Task :expo-dev-launcher-gradle-plugin:processResources
> Task :expo-dev-launcher-gradle-plugin:compileKotlin
> Task :expo-dev-launcher-gradle-plugin:compileJava NO-SOURCE
> Task :expo-dev-launcher-gradle-plugin:classes
> Task :expo-dev-launcher-gradle-plugin:jar
> Task :expo-dev-launcher-gradle-plugin:inspectClassesForKotlinIC
> Task :react-native-gradle-plugin:compileKotlin
> Task :react-native-gradle-plugin:compileJava NO-SOURCE
> Task :react-native-gradle-plugin:classes
> Task :react-native-gradle-plugin:inspectClassesForKotlinIC
> Task :react-native-gradle-plugin:jar
> Configure project :allboatsrise-expo-marketingcloudsdk
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
> Configure project :app
ℹ️  Applying gradle plugin 'expo-dev-launcher-gradle-plugin' ([email protected])
[stderr] 
FAILURE: Build completed with 2 failures.
[stderr] 
1:
[stderr] 
Task failed with an exception.
[stderr] 
-----------
[stderr] 
* Where:
[stderr] 
Build file '/home/expo/workingdir/build/android/app/build.gradle' line: 21
[stderr] 
* What went wrong:
[stderr] 
A problem occurred evaluating project ':app'.
[stderr] 
> path may not be null or empty string. path=''
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
>
[stderr] 
Run with --info or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
2: Task failed with an exception.
[stderr] 
-----------
[stderr] 
* What went wrong:
[stderr] 
A problem occurred configuring project ':app'.
[stderr] 
> compileSdkVersion is not specified. Please add it to build.gradle
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
> Run with --info or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
* Get more help at
[stderr] 
https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
10 actionable tasks: 10 executed
[stderr] 
BUILD FAILED in 2m 10s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

Allow for dynamic app config changes.

Is there a way to allow for a dynamic change for the app config setup in the app.confgi.js file.
Scenario: user changes location so we would like to plug in a different mobile push app based on different locations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.