-
Notifications
You must be signed in to change notification settings - Fork 5
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
CHNL-6305: Added set profile attributes bridge method #135
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5cade5f
initial commit for set profile attributes
ajaysubra 4cfc610
added a new profile property
ajaysubra dffe0fb
removed print
ajaysubra dcfe585
added custom property
ajaysubra 92df59b
Merge branch 'master' into as/chnl-6305-set-profile-attributes
ajaysubra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,11 @@ public class KlaviyoBridge: NSObject { | |
KlaviyoSDK().set(profile: profile) | ||
} | ||
|
||
@objc | ||
public static func setProfileAttribute(_ key: String, value: String) { | ||
KlaviyoSDK().set(profileAttribute: getProfileKey(key), value: value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't really matter, but in the Android code we just used CUSTOM for all incoming keys 🤷
|
||
} | ||
|
||
@objc | ||
public static func setExternalId(_ value: String) { | ||
KlaviyoSDK().set(externalId: value) | ||
|
@@ -154,6 +159,39 @@ public class KlaviyoBridge: NSObject { | |
return .CustomEvent(str) | ||
} | ||
} | ||
|
||
static func getProfileKey(_ str: String) -> Profile.ProfileKey { | ||
switch str { | ||
case ProfileProperty.firstName.rawValue: | ||
return Profile.ProfileKey.firstName | ||
case ProfileProperty.lastName.rawValue: | ||
return Profile.ProfileKey.lastName | ||
case ProfileProperty.address1.rawValue: | ||
return Profile.ProfileKey.address1 | ||
case ProfileProperty.address2.rawValue: | ||
return Profile.ProfileKey.address2 | ||
case ProfileProperty.title.rawValue: | ||
return Profile.ProfileKey.title | ||
case ProfileProperty.organization.rawValue: | ||
return Profile.ProfileKey.organization | ||
case ProfileProperty.city.rawValue: | ||
return Profile.ProfileKey.city | ||
case ProfileProperty.region.rawValue: | ||
return Profile.ProfileKey.region | ||
case ProfileProperty.country.rawValue: | ||
return Profile.ProfileKey.country | ||
case ProfileProperty.zip.rawValue: | ||
return Profile.ProfileKey.zip | ||
case ProfileProperty.image.rawValue: | ||
return Profile.ProfileKey.image | ||
case ProfileProperty.latitude.rawValue: | ||
return Profile.ProfileKey.latitude | ||
case ProfileProperty.longitude.rawValue: | ||
return Profile.ProfileKey.longitude | ||
default: | ||
return Profile.ProfileKey.custom(customKey: str) | ||
} | ||
} | ||
} | ||
|
||
extension Collection where Element: RawRepresentable, Element.RawValue == String { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a couple properties outside of the custom one so that manual testing is easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
Yeah I'd love to update this sample app someday to have an input form here instead of just generating random data.