Skip to content

@wmora wmora released this May 1, 2019 · 1 commit to master since this release

Changes

  • Added new protocol SKTAuthenticationDelegate which gets notified when a request fails because of an invalid JWT, allowing you to renew credentials without having to call [Smooch login:jwt:completionHandler:]. The delegate is set in SKTSettings before initialization.

Sample usage:

@interface MyAppDelegate() <SKTAuthenticationDelegate>

@end

@implementation MyAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    SKTSettings* settings = [SKTSettings settingsWithAppId:@"my_app_id"];
    settings.authenticationDelegate = self;

    [Smooch initWithSettings:settings completionHandler:^(NSError * error, NSDictionary * userInfo) {
        // Code after init is complete
    }];

    return YES;
}

/**
 *  Called when a request failed due to an invalid jwt. Call `completionHandler` to update the token
 */
-(void)onInvalidToken:(NSError *)error handler:(SKTAuthenticationCompletionBlock)completionHandler
{
    // retrieve new token
    completionHandler(newJwt);
}

@end

API Additions

  1. Class SKTSettings
    • Added new property authenticationDelegate
  2. New protocol SKTAuthenticationDelegate
Assets 3
You can’t perform that action at this time.