Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Apps/FCM/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

customerio.reactnative.excludePushMessaging=true
21 changes: 19 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['customerio.reactnative.' + name]).toInteger()
}

// Double negative to include by default
def shouldExcludePushMessaging = getExtOrDefault("excludePushMessaging")

android {
namespace 'io.customer.reactnative.sdk'
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
Expand All @@ -44,6 +47,16 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

sourceSets {
main {
if (shouldExcludePushMessaging) {
java.srcDirs += ['src/push-noop']
} else {
java.srcDirs += ['src/push']
}
}
}
}

repositories {
Expand Down Expand Up @@ -137,10 +150,14 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}
}

apply from: "./cio-core.gradle"

dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation "io.customer.android:datapipelines:$cioAndroidSDKVersion"
implementation "io.customer.android:messaging-in-app:$cioAndroidSDKVersion"
if (!shouldExcludePushMessaging) {
implementation "io.customer.android:messaging-push-fcm:$cioAndroidSDKVersion"
}
}
5 changes: 0 additions & 5 deletions android/cio-core.gradle

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package io.customer.reactnative.sdk.messagingpush

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableMap
import io.customer.sdk.CustomerIOBuilder
import io.customer.sdk.core.di.SDKComponent
import io.customer.sdk.core.util.Logger
import java.lang.IllegalStateException

/**
* ReactNative module to hold push messages features in a single place to bridge with native code.
*/
class RNCIOPushMessaging(
private val reactContext: ReactApplicationContext,
) : ReactContextBaseJavaModule(reactContext) {
override fun getName(): String = "CioRctPushMessaging"

private val logger: Logger = SDKComponent.logger

/**
* Adds push messaging module to native Android SDK based on the configuration provided by
* customer app.
*
* @param builder instance of CustomerIOBuilder to add push messaging module.
* @param config configuration provided by customer app for push messaging module.
*/
internal fun addNativeModuleFromConfig(
builder: CustomerIOBuilder,
config: Map<String, Any>
) {
// No-op
}

@ReactMethod
fun getPushPermissionStatus(promise: Promise) {
throw IllegalStateException("Push messaging is not enabled for CIO")
}

/**
* To request push notification permissions using native apis. Push notifications doesn't
* require permissions for Android versions older than 13, so the results are returned instantly.
* For newer versions, the permission is requested and the promise is resolved after the request
* has been completed.
*
* @param pushConfigurationOptions configurations options for push notifications, required for
* iOS only, unused on Android.
* @param promise to resolve and return the results.
*/
@ReactMethod
fun showPromptForPushNotifications(pushConfigurationOptions: ReadableMap?, promise: Promise) {
throw IllegalStateException("Push messaging is not enabled for CIO")
}

/**
* Handles push notification received. This is helpful in processing push notifications
* received outside the CIO SDK.
*
* @param message push payload received from FCM.
* @param handleNotificationTrigger indicating if the local notification should be triggered.
*/
@ReactMethod
fun handleMessage(message: ReadableMap?, handleNotificationTrigger: Boolean, promise: Promise) {
throw IllegalStateException("Push messaging is not enabled for CIO")
}

/**
* Get the registered device token for the app.
* @returns Promise with device token as a string, or error if no token is
* registered or the method fails to fetch token.
*/
@ReactMethod
fun getRegisteredDeviceToken(promise: Promise) {
throw IllegalStateException("Push messaging is not enabled for CIO")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.customer.reactnative.sdk.messagingpush

/**
* Enum class for wrapping status of Android app permissions.
*/
enum class PermissionStatus {
Granted,
Denied,
}
Loading