diff --git a/CHANGELOG.md b/CHANGELOG.md index c41b6a4..c894e0b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.0+13 + +* Updated Android SDK to 2.2.1, Updated iOS SDK to 3.0.4 + ## 0.0.4+1 * Improved sending events in Android and iOS diff --git a/README.md b/README.md index 48b58db..b6a8d78 100755 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Flutter wrapper for Klaviyo [Android](https://github.com/klaviyo/klaviyo-android-sdk), and [iOS](https://github.com/klaviyo/klaviyo-swift-sdk) projects. -- Uses Klaviyo Android SDK Version `1.1.1`. +- Uses Klaviyo Android SDK Version `2.2.1`. - The minimum Android SDK `minSdkVersion` required is 23. -- Uses Klaviyo iOS SDK Version `2.0.1`. +- Uses Klaviyo iOS SDK Version `3.0.4`. - The minimum iOS target version required is 13. ## Usage diff --git a/android/build.gradle b/android/build.gradle index 70d74e0..e1f1259 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ group 'com.rightbite.denisr' -version '1.0-SNAPSHOT' +version '0.1.0' buildscript { ext.kotlin_version = '1.7.20' @@ -26,7 +26,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 33 + compileSdk 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -42,7 +42,7 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation "com.github.klaviyo.klaviyo-android-sdk:analytics:1.3.4" - implementation "com.github.klaviyo.klaviyo-android-sdk:push-fcm:1.3.4" - implementation 'com.google.firebase:firebase-messaging-ktx:23.1.2' + implementation "com.github.klaviyo.klaviyo-android-sdk:analytics:2.2.1" + implementation "com.github.klaviyo.klaviyo-android-sdk:push-fcm:2.2.1" + implementation 'com.google.firebase:firebase-messaging-ktx:23.4.1' } diff --git a/android/src/main/kotlin/com/rightbite/denisr/KlaviyoFlutterPlugin.kt b/android/src/main/kotlin/com/rightbite/denisr/KlaviyoFlutterPlugin.kt index 799949a..1c9f65f 100644 --- a/android/src/main/kotlin/com/rightbite/denisr/KlaviyoFlutterPlugin.kt +++ b/android/src/main/kotlin/com/rightbite/denisr/KlaviyoFlutterPlugin.kt @@ -5,7 +5,7 @@ import android.content.Context import com.klaviyo.analytics.Klaviyo import com.klaviyo.analytics.model.Event import com.klaviyo.analytics.model.EventKey -import com.klaviyo.analytics.model.EventType +import com.klaviyo.analytics.model.EventMetric import com.klaviyo.analytics.model.Profile import com.klaviyo.analytics.model.ProfileKey import io.flutter.Log @@ -112,7 +112,7 @@ class KlaviyoFlutterPlugin : MethodCallHandler, FlutterPlugin { val metaDataRaw = call.argument?>("metaData") if (eventName != null && metaDataRaw != null) { - val event = Event(EventType.CUSTOM(eventName)) + val event = Event(EventMetric.CUSTOM(eventName)) val metaData = convertMapToSeralizedMap(metaDataRaw) for (item in metaData) { @@ -120,7 +120,7 @@ class KlaviyoFlutterPlugin : MethodCallHandler, FlutterPlugin { } Klaviyo.createEvent(event) - Log.d(TAG, "Event created: $event, type: ${event.type}, value:${event.value} eventMap: ${event.toMap()}") + Log.d(TAG, "Event created: $event, metric: ${event.metric}, value:${event.value} eventMap: ${event.toMap()}") result.success("Event[$eventName] created with metadataMap: $metaData") } } @@ -130,7 +130,7 @@ class KlaviyoFlutterPlugin : MethodCallHandler, FlutterPlugin { call.argument>("message") ?: emptyMap() if (isKlaviyoPush(metaData)) { - val event = Event(EventType.CUSTOM("\$opened_push"), metaData.mapKeys { + val event = Event(EventMetric.CUSTOM("\$opened_push"), metaData.mapKeys { EventKey.CUSTOM(it.key) }) return try { @@ -177,7 +177,7 @@ class KlaviyoFlutterPlugin : MethodCallHandler, FlutterPlugin { } } - private fun isKlaviyoPush(payload: Map) = payload.containsKey("_k") + private fun isKlaviyoPush(payload: Map) = payload.containsKey("com.klaviyo._k") companion object { private const val CHANNEL_NAME = "com.rightbite.denisr/klaviyo" diff --git a/ios/Classes/KlaviyoFlutterPlugin.swift b/ios/Classes/KlaviyoFlutterPlugin.swift index 5ee8042..e9eb8f5 100644 --- a/ios/Classes/KlaviyoFlutterPlugin.swift +++ b/ios/Classes/KlaviyoFlutterPlugin.swift @@ -36,6 +36,15 @@ public class KlaviyoFlutterPlugin: NSObject, FlutterPlugin, UNUserNotificationCe // below method will be called when the user interacts with the push notification public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { + // decrement the badge count on the app icon + if #available(iOS 16.0, *) { + UNUserNotificationCenter.current().setBadgeCount(UIApplication.shared.applicationIconBadgeNumber - 1) + } else { + UIApplication.shared.applicationIconBadgeNumber -= 1 + } + + // If this notification is Klaviyo's notification we'll handle it + // else pass it on to the next push notification service to which it may belong let handled = KlaviyoSDK().handle(notificationResponse: response, withCompletionHandler: completionHandler) if !handled { completionHandler() @@ -116,7 +125,7 @@ public class KlaviyoFlutterPlugin: NSObject, FlutterPlugin, UNUserNotificationCe if let properties = arguments["message"] as? [String: Any], let _ = properties["_k"] { - klaviyo.create(event: Event(name: .OpenedPush, properties: properties, profile: [:])) + klaviyo.create(event: Event(name: .OpenedPush, properties: properties)) return result(true) } diff --git a/ios/klaviyo_flutter.podspec b/ios/klaviyo_flutter.podspec index 8cb3ae2..1555fb0 100644 --- a/ios/klaviyo_flutter.podspec +++ b/ios/klaviyo_flutter.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'klaviyo_flutter' - s.version = '0.0.1' + s.version = '0.1.0' s.summary = 'Klaviyo integration for Flutter' s.description = <<-DESC A new flutter plugin project. @@ -14,7 +14,7 @@ A new flutter plugin project. s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.dependency 'KlaviyoSwift', '~> 2.2.1' + s.dependency 'KlaviyoSwift', '~> 3.0.4' s.ios.deployment_target = '13.0' s.swift_version = '5.0' end diff --git a/pubspec.yaml b/pubspec.yaml index 8d34043..5af1dee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: klaviyo_flutter description: Flutter plugin for Klaviyo integration. Provides push messaging and Klaviyo analitics services -version: 0.0.4+1 +version: 0.1.0+13 homepage: https://github.com/drybnikov/klaviyo_flutter environment: