Skip to content

Commit

Permalink
fix: improve android push click behavior (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 authored Nov 14, 2023
1 parent 79b9bd8 commit 8b1a836
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ customerio.reactnative.kotlinVersion=1.7.21
customerio.reactnative.compileSdkVersion=30
customerio.reactnative.targetSdkVersion=30
customerio.reactnative.minSdkVersion=21
customerio.reactnative.cioSDKVersionAndroid=3.7.0
customerio.reactnative.cioSDKVersionAndroid=3.8.0
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.customer.messaginginapp.ModuleMessagingInApp
import io.customer.messaginginapp.type.InAppEventListener
import io.customer.messagingpush.MessagingPushModuleConfig
import io.customer.messagingpush.ModuleMessagingPushFCM
import io.customer.messagingpush.config.PushClickBehavior
import io.customer.reactnative.sdk.constant.Keys
import io.customer.reactnative.sdk.extension.*
import io.customer.sdk.CustomerIO
Expand Down Expand Up @@ -64,6 +65,7 @@ object CustomerIOReactNativeInstance {
sourceSDK?.equals(
other = "expo", ignoreCase = true,
) == true -> Client.Expo(sdkVersion = sourceSDKVersion)

else -> Client.ReactNative(sdkVersion = sourceSDKVersion)
}
}
Expand Down Expand Up @@ -94,6 +96,16 @@ object CustomerIOReactNativeInstance {
config?.getProperty<Boolean>(Keys.Config.AUTO_TRACK_PUSH_EVENTS)?.let { value ->
setAutoTrackPushEvents(autoTrackPushEvents = value)
}
config?.getProperty<String>(Keys.Config.PUSH_CLICK_BEHAVIOR)
?.takeIfNotBlank()
?.let { value ->
val behavior = kotlin.runCatching {
enumValueOf<PushClickBehavior>(value)
}.getOrNull()
if (behavior != null) {
setPushClickBehavior(pushClickBehavior = behavior)
}
}
}.build(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal object Keys {
const val AUTO_TRACK_PUSH_EVENTS = "autoTrackPushEvents"
const val BACKGROUND_QUEUE_MIN_NUMBER_OF_TASKS = "backgroundQueueMinNumberOfTasks"
const val BACKGROUND_QUEUE_SECONDS_DELAY = "backgroundQueueSecondsDelay"
const val PUSH_CLICK_BEHAVIOR = "pushClickBehaviorAndroid"
}

object PackageConfig {
Expand Down
5 changes: 4 additions & 1 deletion src/CustomerioConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CioLogLevel, Region } from './CustomerioEnum';
import { PushClickBehaviorAndroid } from './types';

/**
* Configure package using CustomerioConfig
Expand All @@ -18,6 +19,8 @@ class CustomerioConfig {
autoTrackPushEvents: boolean = true;
backgroundQueueMinNumberOfTasks: number = 10;
backgroundQueueSecondsDelay: number = 30;
pushClickBehaviorAndroid: PushClickBehaviorAndroid =
PushClickBehaviorAndroid.ActivityPreventRestart;
}

class CustomerIOEnv {
Expand All @@ -38,4 +41,4 @@ class PackageConfig {
source: string = '';
}

export { CustomerioConfig, CustomerIOEnv, PackageConfig };
export { CustomerIOEnv, CustomerioConfig, PackageConfig };
5 changes: 5 additions & 0 deletions src/types/PushClickBehaviorAndroid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum PushClickBehaviorAndroid {
ResetTaskStack = 'RESET_TASK_STACK',
ActivityPreventRestart = 'ACTIVITY_PREVENT_RESTART',
ActivityNoFlags = 'ACTIVITY_NO_FLAGS',
}
1 change: 1 addition & 0 deletions src/types/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './PushClickBehaviorAndroid';
export * from './PushPermissionOptions';
export * from './PushPermissionStatus';

0 comments on commit 8b1a836

Please sign in to comment.