@grabjs/superapp-sdk
    Preparing search index...

    Class UserAttributesModule

    JSBridge module for reading user-related attributes from native code.

    Provides access to user and traveller attributes exposed by the native Grab app bridge. This code must run on the Grab SuperApp's WebView to function correctly.

    ES Module:

    import { UserAttributesModule } from '@grabjs/superapp-sdk';
    const userAttributesModule = new UserAttributesModule();

    CDN (UMD):

    <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
    <script>
    const userAttributesModule = new SuperAppSDK.UserAttributesModule();
    </script>

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Returns the currently selected travel destination as a lowercase ISO 3166-1 alpha-2 country code.

      Returns Promise<GetSelectedTravelDestinationResponse>

      The selected travel destination lowercase ISO 3166-1 alpha-2 country code when available.

      Simple usage

      import { UserAttributesModule, isSuccess, isErrorResponse } from '@grabjs/superapp-sdk';

      // Initialize the user attributes module
      const userAttributes = new UserAttributesModule();

      // Read the selected travel destination
      const response = await userAttributes.getSelectedTravelDestination();

      // Handle the response
      if (isSuccess(response)) {
      switch (response.status_code) {
      case 200:
      console.log('Selected travel destination code:', response.result);
      break;
      case 204:
      console.log('Selected travel destination is not available');
      break;
      }
      } else if (isErrorResponse(response)) {
      console.error(`Error ${response.status_code}: ${response.error}`);
      } else {
      console.error('Unhandled response');
      }