Kigo Global Object

The Kigo global object is the primary interface for interacting with and configuring the Kigo Loyalty Wallet SDK. It provides methods to customize the SDK's behavior, manage user sessions, and handle important events like initialization and authorization.

Key Methods and Properties

1. setContext(context: Partial<KigoContext>)

  • Purpose: Dynamically update the SDK’s configuration by merging your custom context with the existing one.
  • Example Usage:
    Kigo.setContext({
      theme: {
        palette: {
          primary: "#FF5733",
        },
      },
      user: {
        name: "Jane Doe",
      },
    });
    
  • Learn More: See the KigoContext section for a full breakdown of configurable options.

2. isReady: boolean

  • Purpose: Indicates whether the SDK is fully initialized and ready to be used.
  • Usage Tip: Check Kigo.isReady before performing any operations to ensure the SDK is fully loaded.

3. onReady(kigo: Kigo)

  • Purpose: A callback that is triggered when the SDK is ready. Use this to perform initial setup tasks.
  • Example Usage:
    Kigo.onReady = function (kigo) {
      kigo.setContext({
        theme: {
          palette: {
            primary: "#FF5733",
          },
        },
      });
    };
    
  • Learn More: Getting started

4. onAuthorizationError(error: unknown | Error)

  • Purpose: Handle authorization errors such as expired or invalid tokens.
  • Example Usage:
    Kigo.onAuthorizationError = function (error) {
      console.error("Authorization error:", error);
      // Handle token renewal or re-authentication
    };
    
  • Related Section: Authorization Handling

5. setAuthorizationToken(token: string)

  • Purpose: Set the authorization token used for authenticating API requests.
  • Example Usage:
    Kigo.setAuthorizationToken("your-auth-token");
    
  • Related Section: Authorization Handling

When and How to Use

  • During Initialization: Use Kigo.onReady to set up your initial configuration, ensuring the SDK is ready before any operations are performed.
  • Asynchronous Updates: Use Kigo.setContext to dynamically update the SDK’s settings and user information as needed.

Summary

The Kigo global object provides essential methods for configuring and managing the Kigo Loyalty Wallet SDK. For more details on specific methods, refer to the relevant sections linked above.

For more detailed information on each of these methods, check out the corresponding sections linked above.


What’s Next