Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve android push click behavior #203

Merged
merged 9 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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: 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.6.6
customerio.reactnative.cioSDKVersionAndroid=rehan-push-click-behavior-SNAPSHOT
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)
}
}
Shahroz16 marked this conversation as resolved.
Show resolved Hide resolved
}.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';
Loading