Skip to content

Commit

Permalink
chore: add “identifyUser” API
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Oct 14, 2022
1 parent 2656294 commit d952869
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ See the [app.js](./example/app.js) for a full-featured example!

Initializes the SDK. The `domain` is optional.

### `identifyUser(externalId)`

Identifies a user with Freshchat for usage with an external user ID (e.g. of your own database)

### `signInUser({ firstName, lastName, email })`

Authenticates a user with Freshchat. All values are optional!
Signs in a user with Freshchat. All values are optional!

### `updateUserProperty(key, value)`

Expand Down
5 changes: 5 additions & 0 deletions android/src/ti/freshchat/TitaniumFreshchatModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class TitaniumFreshchatModule: KrollModule() {
instance().init(config)
}

@Kroll.method
fun identifyUser(externalId: String) {
instance().identifyUser(externalId, null)
}

@Kroll.method
fun signInUser(params: KrollDict) {
val firstName = params.getString("firstName")
Expand Down
9 changes: 8 additions & 1 deletion ios/Classes/TiFreshchatModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class TiFreshchatModule: TiModule {
Freshchat.sharedInstance().initWith(config)
}

@objc(identifyUser:)
func identifyUser(args: [Any]) {
guard let externalId = args.first as? String else { fatalError("Missing parameters") }

Freshchat.sharedInstance().identifyUser(withExternalID: externalId, restoreID: nil)
}

@objc(signInUser:)
func signInUser(args: [Any]) {
guard let params = args.first as? [String: String] else { fatalError("Missing parameters") }
Expand All @@ -71,7 +78,7 @@ class TiFreshchatModule: TiModule {
}

if let email = params["email"] {
//To set user's email id
// To set user's email
user.email = email
}

Expand Down

0 comments on commit d952869

Please sign in to comment.