diff --git a/android/build.gradle b/android/build.gradle index 82e2862..08127ad 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -58,7 +58,7 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Customer.io SDK - def cioVersion = "[3.3,4.0)" + def cioVersion = "[3.4.2,4.0)" implementation "io.customer.android:tracking:$cioVersion" implementation "io.customer.android:messaging-push-fcm:$cioVersion" implementation "io.customer.android:messaging-in-app:$cioVersion" diff --git a/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt b/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt index 299313b..efc77f9 100644 --- a/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt +++ b/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt @@ -91,44 +91,53 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { initialize(it) } } + Keys.Methods.IDENTIFY -> { call.toNativeMethodCall(result) { identify(it) } } + Keys.Methods.SCREEN -> { call.toNativeMethodCall(result) { screen(it) } } + Keys.Methods.TRACK -> { call.toNativeMethodCall(result) { track(it) } } + Keys.Methods.TRACK_METRIC -> { call.toNativeMethodCall(result) { trackMetric(it) } } + Keys.Methods.REGISTER_DEVICE_TOKEN -> { call.toNativeMethodCall(result) { registerDeviceToken(it) } } + Keys.Methods.SET_DEVICE_ATTRIBUTES -> { call.toNativeMethodCall(result) { setDeviceAttributes(it) } } + Keys.Methods.SET_PROFILE_ATTRIBUTES -> { call.toNativeMethodCall(result) { setProfileAttributes(it) } } + Keys.Methods.CLEAR_IDENTIFY -> { clearIdentity() } + else -> { result.notImplemented() } @@ -214,7 +223,11 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { Keys.Environment.ENABLE_IN_APP ) - CustomerIO.Builder( + // Checks if SDK was initialized before, which means lifecycle callbacks are already + // registered as well + val isLifecycleCallbacksRegistered = kotlin.runCatching { CustomerIO.instance() }.isSuccess + + val customerIO = CustomerIO.Builder( siteId = siteId, apiKey = apiKey, region = Region.getRegion(region), @@ -236,6 +249,17 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { } }.build() logger.info("Customer.io instance initialized successfully") + + // Request lifecycle events for first initialization only as relaunching app + // in wrapper SDKs may result in reinitialization of SDK and lifecycle listener + // will already be attached in this case as they are registered to application object. + if (!isLifecycleCallbacksRegistered) { + activity?.get()?.let { activity -> + logger.info("Requesting delayed activity lifecycle events") + val lifecycleCallbacks = customerIO.diGraph.activityLifecycleCallbacks + lifecycleCallbacks.postDelayedEventsForNonNativeActivity(activity) + } + } } private fun configureModuleMessagingPushFCM(config: Map?): ModuleMessagingPushFCM { diff --git a/ios/customer_io.podspec b/ios/customer_io.podspec index fef1f7f..b55f53d 100755 --- a/ios/customer_io.podspec +++ b/ios/customer_io.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'customer_io' - s.version = '1.0.0' + s.version = '1.1.1' s.summary = 'Customer.io plugin for Flutter' s.homepage = 'https://customer.io/' s.license = { :file => '../LICENSE' } @@ -13,8 +13,8 @@ Pod::Spec.new do |s| s.source_files = 'Classes/**/*' s.dependency 'Flutter' s.platform = :ios, '13.0' - s.dependency "CustomerIOTracking", '~> 2.1.2' - s.dependency "CustomerIOMessagingInApp", '~> 2.1.2' + s.dependency "CustomerIOTracking", '~> 2.3.0' + s.dependency "CustomerIOMessagingInApp", '~> 2.3.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } diff --git a/lib/customer_io_plugin_version.dart b/lib/customer_io_plugin_version.dart index 3f2f97f..5ce2c61 100755 --- a/lib/customer_io_plugin_version.dart +++ b/lib/customer_io_plugin_version.dart @@ -1,2 +1,2 @@ // Don't modify this line - it's automatically updated -const version = "1.0.0"; +const version = "1.1.1";