Skip to content

Commit

Permalink
added method bindings for registering device token
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 committed Nov 13, 2024
1 parent c1ec3de commit 4946541
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}

private fun registerDeviceToken(params: Map<String, Any>) {
// TODO: Fix registerDeviceToken implementation
/*
val token = params.getString(Keys.Tracking.TOKEN)
val token = requireNotNull(params.getAsTypeOrNull<String>(Keys.Tracking.TOKEN)) {
"Device token is missing in params: $params"
}
CustomerIO.instance().registerDeviceToken(token)
*/
}

private fun trackMetric(params: Map<String, Any>) {
Expand Down
22 changes: 12 additions & 10 deletions ios/Classes/SwiftCustomerIoPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,22 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin {

private func setProfileAttributes(params : Dictionary<String, AnyHashable>){
guard let attributes = params[Keys.Tracking.traits] as? Dictionary<String, AnyHashable>
else { return }
else {
logger.error("Missing attributes in: \(params) for key: \(Keys.Tracking.traits)")
return
}

CustomerIO.shared.profileAttributes = attributes
}

private func registerDeviceToken(params : Dictionary<String, AnyHashable>){
// TODO: Fix registerDeviceToken implementation
/*
guard let token = params[Keys.Tracking.token] as? String
else {
return
}

CustomerIO.shared.registerDeviceToken(token)
*/
guard let token = params[Keys.Tracking.token] as? String
else {
logger.error("Missing token in: \(params) for key: \(Keys.Tracking.token)")
return
}

CustomerIO.shared.registerDeviceToken(token)
}

private func trackMetric(params : Dictionary<String, AnyHashable>){
Expand Down

0 comments on commit 4946541

Please sign in to comment.