From 04b15ede22ef20bebb17aae072ee7311038a0759 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 14:02:27 +0500 Subject: [PATCH] profile attributes --- .../io/customer/customer_io/CustomerIoPlugin.kt | 5 +---- ios/Classes/SwiftCustomerIoPlugin.swift | 11 +++-------- lib/customer_io_const.dart | 3 ++- lib/customer_io_method_channel.dart | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) 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 a621335..4e1fb75 100644 --- a/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt +++ b/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt @@ -221,12 +221,9 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { } private fun setProfileAttributes(params: Map) { - // TODO: Fix setProfileAttributes implementation - /* - val attributes = params.getProperty>(Keys.Tracking.ATTRIBUTES) ?: return + val attributes = params.getAsTypeOrNull>(Keys.Tracking.TRAITS) ?: return CustomerIO.instance().profileAttributes = attributes - */ } private fun screen(params: Map) { diff --git a/ios/Classes/SwiftCustomerIoPlugin.swift b/ios/Classes/SwiftCustomerIoPlugin.swift index caba065..bc5e665 100644 --- a/ios/Classes/SwiftCustomerIoPlugin.swift +++ b/ios/Classes/SwiftCustomerIoPlugin.swift @@ -139,14 +139,9 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { } private func setProfileAttributes(params : Dictionary){ - // TODO: Fix setProfileAttributes implementation - /* - guard let attributes = params[Keys.Tracking.attributes] as? Dictionary - else { - return - } - CustomerIO.shared.profileAttributes = attributes - */ + guard let attributes = params[Keys.Tracking.traits] as? Dictionary + else { return } + CustomerIO.shared.profileAttributes = attributes } private func registerDeviceToken(params : Dictionary){ diff --git a/lib/customer_io_const.dart b/lib/customer_io_const.dart index b7dfa58..c6ca7a1 100644 --- a/lib/customer_io_const.dart +++ b/lib/customer_io_const.dart @@ -13,7 +13,8 @@ class MethodConsts { } class TrackingConsts { - static const String identifier = "identifier"; + static const String userId = "userId"; + static const String traits = "traits"; static const String attributes = "attributes"; static const String eventName = "eventName"; static const String token = "token"; diff --git a/lib/customer_io_method_channel.dart b/lib/customer_io_method_channel.dart index 6c70669..5e71dcd 100644 --- a/lib/customer_io_method_channel.dart +++ b/lib/customer_io_method_channel.dart @@ -170,7 +170,7 @@ class CustomerIOMethodChannel extends CustomerIOPlatform { @override void setProfileAttributes({required Map attributes}) { try { - final payload = {TrackingConsts.attributes: attributes}; + final payload = {TrackingConsts.traits: attributes}; methodChannel.invokeMethod(MethodConsts.setProfileAttributes, payload); } on PlatformException catch (exception) { handleException(exception);