SCSAuthenticationSettings

@interface SCSAuthenticationSettings : NSObject

Authentication settings for the Snap-ins SDK. This class is necessary if you want to use any of the SDK features in authenticated mode. You’ll need to authenticate, for instance, if you want to access a knowledge base only accessible to logged in users, or if you want a user to view and manage their cases. Create an instance of this class using one of the provided initialization methods.

You can either authenticate explicitly using -[SCServiceCloud setAuthenticationSettings:forServiceType:completion:] or you can authenticate on-demand by implementing -[SCServiceCloudDelegate serviceCloud:shouldAuthenticateServiceType:completion:].

To learn more about authentication, see Authentication.

  • Indicates whether these settings apply to a guest user who is not authenticated.

    Declaration

    Objective-C

    @property (readonly, getter=isGuestUser, assign, nonatomic) BOOL guestUser;

    Swift

    var isGuestUser: Bool { get }
  • Indicates whether the specified authentication settings are valid.

    Declaration

    Objective-C

    @property (readonly, getter=areSettingsValid, assign, nonatomic)
        BOOL settingsValid;

    Swift

    var areSettingsValid: Bool { get }
  • Indicates whether the settings are being verified.

    Declaration

    Objective-C

    @property (readonly, getter=isVerifyingSettings, assign, nonatomic)
        BOOL verifyingSettings;

    Swift

    var isVerifyingSettings: Bool { get }
  • The name of the user for these authentication settings.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSString *username;

    Swift

    var username: String? { get }
  • Initializes this object as a guest user who is not authenticated.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithGuestCommunityUrl:(nonnull NSURL *)communityUrl;

    Swift

    init(guest communityUrl: URL)

    Parameters

    communityUrl

    The URL of the community that accepts guest users.

  • Initializes this object using a dictionary of authentication settings. Refer to SCSOAuth2JSONKey for information about which dictionary keys are required.

    Declaration

    Objective-C

    - (nullable instancetype)
    initWithOAuth2Dictionary:
        (nonnull NSDictionary<SCSOAuth2JSONKey, NSString *> *)dictionary
                    clientId:(nonnull NSString *)clientId;

    Swift

    init?(oauth2 dictionary: [SCSOAuth2JSONKey : String], clientId: String)

    Parameters

    dictionary

    The dictionary of authentication settings. The keys are of type SCSOAuth2JSONKey and the values are strings.

    clientId

    The unique client ID for these authentication settings.

  • Initializes this object with a user account from the Salesforce Mobile SDK. This method automatically extracts all relevant information from the user account.

    Declaration

    Objective-C

    - (nullable instancetype)initWithMobileSDKAccount:
        (nonnull SFUserAccount *)account;

    Swift

    init?(mobileSDK account: SFUserAccount)

    Parameters

    account

    The mobile SDK user account from which to extract authentication settings.

  • Undocumented

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Verifies that the authentication settings are valid.

    Declaration

    Objective-C

    - (void)verifySettingsWithCompletion:
        (nonnull void (^)(BOOL, NSError *_Nullable __strong))completion;

    Swift

    func verifySettings(completion: @escaping (Bool, Error?) -> Void)

    Parameters

    completion

    Completion block that is called after the verification process.

  • Indicates whether the account has been registered for notifications.

    Declaration

    Objective-C

    @property (readonly, getter=isRegisteredForPushNotifications, assign, nonatomic)
        BOOL registeredForPushNotifications;

    Swift

    var isRegisteredForPushNotifications: Bool { get }
  • Indicates if the account is able to register for push notifications.

    Declaration

    Objective-C

    - (BOOL)supportsPushNotifications;

    Swift

    func supportsPushNotifications() -> Bool

    Return Value

    YES if this account can support registering for push notifications.

  • Registers the given device token for push notifications for the given account. If the current account is already registered, it automatically unregisters the previous token.

    Declaration

    Objective-C

    - (void)registerForPushNotifications:(nonnull NSData *)deviceToken
                              completion:
                                  (nullable void (^)(
                                      BOOL, NSError *_Nullable __strong))completion;

    Swift

    func register(forPushNotifications deviceToken: Data, completion: ((Bool, Error?) -> Void)? = nil)

    Parameters

    deviceToken

    Device token supplied by the -[UIApplicationDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:] method.

    completion

    Completion block that is called after the registration attempt.

  • Unregisters the account from push notification support.

    Declaration

    Objective-C

    - (void)unregisterForPushNotifications:
        (nullable void (^)(BOOL, NSError *_Nullable __strong))completion;

    Swift

    func unregister(forPushNotifications completion: ((Bool, Error?) -> Void)? = nil)

    Parameters

    completion

    Completion block that is called after the attempt to unregister.