@wmora wmora released this Sep 18, 2017 · 33 commits to master since this release

Assets 3

v6.0.0

This major version introduces a new optimized initialization sequence which changes when key events like creating an appUser or establishing a websocket connection are happening. These changes result in reduced usage of the CPU and networking resources, and reduced energy impact of the SDK.

Behaviour Changes

  • Initialization is no longer done with an appToken. Use your Smooch app's _id instead.
// Before
SKTSettings* settings = [SKTSettings settingsWithAppToken:@"YOUR_APP_TOKEN"];
[Smooch initWithSettings:settings];

// After
SKTSettings* settings = [SKTSettings settingsWithAppId:@"YOUR_APP_ID"];
[Smooch initWithSettings:settings completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
    // Handle init result
}];
  • jwt credential is now required when calling the login:jwt:completionHandler: API. You can no longer assign userIds to users without using a JWT to secure the userId.
// Before
[Smooch login:@"a_user_id" jwt:nil];

// After
[Smooch login:@"a_user_id" jwt:@"a_jwt" completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
    // Your code after login is complete
}];
  • Users are no longer automatically created at initialization time. Instead, a user is created when they send their first message. This means that the SKTUser instance is no longer guaranteed to have an appUserId after SKTInitializationDidCompleteNotification.
  • SKTInitializationDidCompleteNotification and SKTInitializationDidFailNotification notifications are no longer fired on login and logout. Use the newly added notifications for login/logout, or the block callbacks instead
// Before
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethod:) name:SKTInitializationDidCompleteNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethod:) name:SKTInitializationDidFailNotification object:nil];

-(void)someMethod:(NSNotification*)notification
{
    // Handle init, login, logout result
}

// After
[Smooch initWithSettings:settings completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
    // Handle init result
}];

[Smooch login:@"a_user_id" jwt:@"a_jwt" completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
    // Handle login result
}];

[Smooch logoutWithCompletionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
    // Handle logout result
}];
  • userId and jwt can no longer be passed through SKTSettings. You must either call login:jwt:completionHandler: or logoutWithCompletionHandler: to switch users. Note that login sessions are still persisted across application launches.
// Before
SKTSettings* settings = [SKTSettings settingsWithAppToken:@"YOUR_APP_TOKEN"];
settings.userId = @"a_user_id";
settings.jwt = @"a_jwt";
[Smooch initWithSettings:settings];

// After
SKTSettings* settings = [SKTSettings settingsWithAppId:@"YOUR_APP_ID"];
[Smooch initWithSettings:settings completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
    if (!error) {
        [Smooch login:@"a_user_id" jwt:@"a_jwt" completionHandler:nil];
    }
}];
  • Removed support for Whispers

API Changes (Breaking)

  1. Class Smooch
    • Replaced method +initWithSettings: with +initWithSettings:completionHandler:
    • Replaced method +login:jwt: with +login:jwt:completionHandler:
    • Replaced method +logout with +logoutWithCompletionHandler:
    • Removed method +track:
  2. Class SKTSettings
    • Replaced method +settingsWithAppToken: with +settingsWithAppId:
    • Replaced property appToken with appId
    • Removed properties userId and jwt
  3. Class SKTUser
    • Renamed property smoochId to appUserId
  4. Class SKTConversation
    • Added property hasPreviousMessages
    • Removed property previous, use hasPreviousMessages instead
  5. Protocol SKTConversationDelegate
    • Removed method -conversation:shouldShowForAction:, use -conversation:shouldShowForAction:withInfo: instead
  6. Class SKTMessage
    • Removed properties isWhisper and ruleId

API Additions

  1. Class Smooch
    • Added new notifications SKTLoginDidCompleteNotification, SKTLoginDidFailNotification, SKTLogoutDidCompleteNotification, and SKTLogoutDidFailNotification
    • Added new constants SKTUserIdentifier, SKTErrorDescriptionIdentifier, and SKTErrorDomainIdentifier