as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

useIapUserData

useIapUserData(getUserDataRequest): object

useIapUserData hook should be called in your main screen component. This hook automatically invokes getUserData API and populates states during main screen launch and App state transitions from BG -> FG. "iapUserData" state returned by this hook will help you to make sure that you retrieve the receipts for the current user account.

This hook handles case where the user switched account when your app went to background. State "iapUserData" will be populated when the app comes to foreground and would trigger your logic to retrieve receipts for the current user.

Sample Usage:
   export const AppMainPage = () => {
      // Calling useIapUserData in main screen
      const {iapUserDataLoading, iapUserDataError, iapUserData} = useIapUserData({});
      ...
      ...
      // Once Userdata is loaded, call handler
      if (!iapUserDataLoading) {
         if (iapUserDataError) {
            // Handle Error based on iapUserData.responseCode
            ...
         } else {
            // Persist the iapUserData.userId and retrieve receipts for this user.
            ...
         }
      }
      ...
   }

Parameters

getUserDataRequest

UserDataRequest

User Data request parameters

Returns

object

States and value of user data

iapUserData

iapUserData: any

iapUserDataError

iapUserDataError: any

iapUserDataLoading

iapUserDataLoading: any


Last updated: Sep 30, 2025