Closed pehagg closed 1 month ago
Try this, based on docs here: https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/MarketingCloudSdk/8.0/-marketing%20-cloud%20-s-d-k/com.salesforce.marketingcloud.analytics/index.html
AsyncFunction("isAnalyticsEnabled") { promise: Promise ->
whenPushModuleReady(promise) { mp -> promise.resolve(mp.analyticsManager.areAnalyticsEnabled()) }
}
AsyncFunction("enableAnalytics") { promise: Promise ->
whenPushModuleReady(promise) { mp ->
mp.analyticsManager.enableAnalytics()
promise.resolve(mp.analyticsManager.enableAnalytics())
}
}
AsyncFunction("disableAnalytics") { promise: Promise ->
whenPushModuleReady(promise) { mp ->
mp.analyticsManager.disableAnalytics()
promise.resolve(mp.analyticsManager.areAnalyticsEnabled())
}
}
If you can submit a PR that would be great!
Released in 51.0.6
Due to GDPR, we cannot enable analytics until the user has given consent for this. react-native-marketingcloudsdk has support for this, but I couldn't find any traces of being able to control this programmatically for expo-marketingcloudsdk.
I got this working for iOS by adding three new functions
isAnalyticsEnabled
,enableAnalytics
, anddisableAnalytics
(in the spirit ofisPushEnabled
,enablePush
, anddisablePush
), but I'm struggling with finding the correct way to do this for Android.Any help would be appreciated, I can even post a PR of the changes later. This is the only thing that is preventing us from migrating our app to Expo.