SKTUser
Objective-C
@interface SKTUser : NSObject
Swift
class SKTUser : NSObject
A class representing a user.
-
@abstract The object representing the current user.
@discussion Returns nil if +initWithSettings:completionHandler: has not been called yet.
See
SmoochDeclaration
Objective-C
+ (nullable instancetype)currentUser;
Swift
class func current() -> Self?
-
@abstract Adds custom metadata to the user. This info is used to provide more context around who a user is.
@discussion Keys must be of type NSString, and values must be of type NSString, NSNumber, or NSDate; any other type will be converted to NSString using the -description method.
Example:
[user addMetadata:@{ @"nickname" : @"Lil' Big Daddy Slim", @"weight" : @650, @"premiumUser" : @YES }];
Changes to user metadata are uploaded in batches at regular intervals, when the app is sent to the background, or when a message is sent.
This API is additive, and subsequent calls will override values for the provided keys.
Declaration
Objective-C
- (void)addMetadata:(nonnull NSDictionary *)metadata;
Swift
func addMetadata(_ metadata: [AnyHashable : Any])
Parameters
metadata
The metadata to set for the current user.
-
@abstract The assigned userId for this user.
@discussion Unlike
externalId
, this property is set automatically by Smooch, and is not configurable. This is analogous toappUser._id
in the REST API response. A user is assigned anuserId
once they start a conversation or when an existing user is logged in by calling +login:jwt:completionHandler:.See
SmoochDeclaration
Objective-C
@property (readonly, nullable) NSString *userId;
Swift
var userId: String? { get }
-
@abstract The assigned externalId for this user.
@discussion This property is set by calling +login:jwt:completionHandler:.
Unlike
userId
, this value is assigned and managed by the developer, and is used to identify a user across devices and app installations.See
SKTSettingsSee
SmoochDeclaration
Objective-C
@property (readonly, nullable) NSString *externalId;
Swift
var externalId: String? { get }
-
@abstract The user’s first name, to be used as part of the display name when sending messages.
Declaration
Objective-C
@property (copy, nullable) NSString *firstName;
Swift
var firstName: String? { get set }
-
@abstract The user’s custom metadata.
Declaration
Objective-C
@property (copy, readonly) NSDictionary *_Nonnull metadata;
Swift
var metadata: [AnyHashable : Any] { get }
-
@abstract The user’s last name, to be used as part of the display name when sending messages.
Declaration
Objective-C
@property (copy, nullable) NSString *lastName;
Swift
var lastName: String? { get set }
-
@abstract The user’s email, to be used to display a gravatar.
Declaration
Objective-C
@property (copy, nullable) NSString *email;
Swift
var email: String? { get set }
-
@abstract The date the user started using your service.
Declaration
Objective-C
@property (copy, nullable) NSDate *signedUpAt;
Swift
var signedUpAt: Date? { get set }