as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

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: Oct 02, 2025