Options
All
  • Public
  • Public/Protected
  • All
Menu

@snapchat/snap-kit-react-native

Index

Enumerations

Interfaces

Type aliases

Variables

Type aliases

LoginKitType

LoginKitType: { login: any; isUserLoggedIn: any; getAccessToken: any; refreshAccessToken: any; clearToken: any; hasAccessToScope: any; fetchUserData: any; verify: any; verifyAndLogin: any }

Type declaration

  • login: function
    • login(): Promise<void>
    • Begins the authentication flow using OAuth by linking into the Snapchat app. If the user does not have the Snapchat app installed, it will open up a WebView to Snapchat’s web authentication page.

      You can register for LoginState updates using the DeviceEventEmitter, for example:

        const eventCallbackLoginStarted = () => {
           // handle event emitted
         };
      
       // Subscribing to event
       const loginStartedListener = DeviceEventEmitter.addListener(
          LoginState.LOGIN_KIT_LOGIN_STARTED,
          eventCallbackLoginStarted
        );
      
       // Unsubscribing to event
       loginStartedListener.removeListener();
      

      Returns Promise<void>

      Promise resolves when login is successful or rejects when login fails.

  • isUserLoggedIn: function
    • isUserLoggedIn(): Promise<boolean>
    • Checks if the user is authenticated using Snapchat and has a valid auth token.

      Returns Promise<boolean>

      Promise resolves true if the user is authenticated using Snapchat, false otherwise.

  • getAccessToken: function
    • getAccessToken(): Promise<null | string>
    • Returns the current local access token for the logged in user.

      Note: If this method returns null, the access token may need to be refreshed by calling refreshAccessToken().

      Returns Promise<null | string>

      Promise resolves null if there is no access token or the access token.

  • refreshAccessToken: function
    • refreshAccessToken(): Promise<string>
    • Refreshes the user's access token.

      Returns Promise<string>

      Promise resolves with the new access token or rejects if an access token cannot be refreshed.

  • clearToken: function
    • clearToken(): void
    • Method to clear the access token. This method is used for logging out the user.

      Returns void

  • hasAccessToScope: function
    • Determines whether the user has authorized the current session to have access to resources with the requested scope.

      Parameters

      Returns Promise<boolean>

      Promise resolves true if the current session has access to resources with the scope, false otherwise.

  • fetchUserData: function
    • fetchUserData(query: string, variables: null | Record<string, any>): Promise<UserData>
    • Method to fetch user data based on the scopes requested.

      Parameters

      • query: string

        GraphQL query to request user data.

      • variables: null | Record<string, any>

        Record of variables for your GraphQL request.

      Returns Promise<UserData>

      Promise resolves with returned user data or rejects if there was an issue fetching the data.

  • verify: function
    • verify(phoneNumber: string, countryCode: string): Promise<VerifyResponse>
    • Start the flow for Verify with Snapchat.

      This checks an inputted phone number and verify that it matched the one on file for the user's Snapchat account. Users will be redirected to Snapchat to verify their phone number; once the number has been confirmed, user will return back to the app.

      Note: This API is currently only supported on iOS.

      Parameters

      • phoneNumber: string

        A phone number with appropriate area codes that needs to be verified.

        This should follow the National Format specified by the ITU-T Recommendation E.123.

        For example, (302) 123-4567 is the National Format for this International Number +1 (302) 123-4567.

        Note that the number doesn't specifically need to be formatted with Parentheses, Hyphens, Spaces, or other separating symbols and so 3021234567 will also work.

      • countryCode: string

        The two-letter country code (as per the ISO 3166-1 alpha-2 ) in upper-case that represents the country this phone number applies to.

        For example, US is the country code for this International Number +1 (302) 123-4567.

      Returns Promise<VerifyResponse>

      Promise resolves with returned verify response or rejects if there was an issue during verification.

  • verifyAndLogin: function
    • verifyAndLogin(phoneNumber: string, countryCode: string): Promise<VerifyResponse>
    • Start the flow for Verify and Login with Snapchat.

      This checks an inputted phone number and verify that it matched the one on file for the user's Snapchat account. Users will be redirected to Snapchat to verify their phone number; once the number has been confirmed, they will be redirected to the Login / OAuth modal. After authorization, user will return back to the app.

      Note: This API is currently only supported on iOS.

      Parameters

      • phoneNumber: string

        A phone number with appropriate area codes that needs to be verified.

        This should follow the National Format specified by the ITU-T Recommendation E.123.

        For example, (302) 123-4567 is the National Format for this International Number +1 (302) 123-4567.

        Note that the number doesn't specifically need to be formatted with Parentheses, Hyphens, Spaces, or other separating symbols and so 3021234567 will also work.

      • countryCode: string

        The two-letter country code (as per the ISO 3166-1 alpha-2 ) in upper-case that represents the country this phone number applies to.

        For example, US is the country code for this International Number +1 (302) 123-4567.

      Returns Promise<VerifyResponse>

      Promise resolves with returned verify response or rejects if there was an issue during verification.

Variables

Const LoginKit

LoginKit: LoginKitType = ...

Generated using TypeDoc