ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Mobile specific functions / In-App Purchase functions
  • Special cases
  • Application in the background: Specific case from Android 10
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Sends:
  • a request for purchasing an "In-App" product associated with the application.
  • a request for purchasing a subscription.
Remark: The purchase request is asynchronous. A "Callback" procedure is run when receiving the response to the purchase request.
Example
MyProduct is inAppProduct = arrProduct[nIndex]
inAppPurchaseProduct(MyProduct, ValidateProductPurchase)
PROCÉDURE ValidateProductPurchase(bSuccess is boolean, Product is inAppProduct, Receipt)
 
IF NOT bSuccess THEN
ToastDisplay(ErrorInfo())
RETURN
ELSE
// Android case
IF InAndroidMode() THEN
// Consume the product (optional)
inAppConsumeProduct(Product, Receipt, ConsumeProduct)
END
// iOS case
IF IniOSMode() THEN
// Activate the product in the application
EnableProduct(Product)
// Save the purchase in the application preferences
SaveParameter(Product.Identifier, 1)
END
END
Syntax
iPhone/iPad

iOS: Sending a purchase request Hide the details

<Result> = inAppPurchaseProduct(<Product to purchase> , <Quantity> , <WLanguage procedure>)
<Result>: Boolean
  • True if the purchase request was performed,
  • False otherwise. To get more details on the error, use ErrorInfo.
<Product to purchase>: inAppProduct variable
Name of inAppProduct variable corresponding to:
  • the product to purchase.
  • the subscription to purchase or to renew.
<Quantity>: Integer
Quantity to purchase.
  • For a subscription, this parameter must correspond to 1.
  • If the value of this parameter is equal to 0, <Result> is set to False and the procedure is not called.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") executed when the purchase request response is received. For more details on this procedure, see Parameters of the procedure used by inAppPurchaseProduct.
Android

Android: Sending a purchase request Hide the details

<Result> = inAppPurchaseProduct(<Product to purchase> , <WLanguage procedure>)
<Result>: Boolean
  • True if the purchase request was performed,
  • False otherwise. To get more details on the error, use ErrorInfo.
<Product to purchase>: inAppProduct variable
Name of inAppProduct variable corresponding to:
  • the product to purchase.
  • the subscription to purchase or to renew.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") executed when the purchase request response is received. For more details on this procedure, see Parameters of the procedure used by inAppPurchaseProduct.
Remarks

Special cases

  • If the purchase is valid, the application must supply the purchase content to the user.
  • iPhone/iPad If the purchase was performed, the application must store this information. This information can be stored in the preferences by SaveParameter.
  • If inAppPurchaseProduct is used to purchase a subscription that is already active for the user, this subscription is automatically extended for the corresponding period.
  • Android You cannot purchase a product that was already purchased by the user. The product must be consumed (with inAppConsumeProduct) before it can be purchased again.
    inAppListPurchase is used to retrieve the products purchased by the user and not consumed yet.
  • Android You cannot specify the quantity of products to purchase. You must create products corresponding to the desired quantity in the Google Play developer console. Then, the application must manage the use of the purchased quantities.
  • Android You cannot perform several requests for purchase at the same time. You must wait for the response to a request before performing a new request.
  • Android inAppPurchaseProduct has no effect if it is run from the Android simulator or emulator.
Android

Application in the background: Specific case from Android 10

From Android 10, it is no longer possible to open a window when the application is in the background.
inAppPurchaseProduct can open a window. If this function is used while the application is in the background, a fatal error will occur.
Tips:
  • It is possible to determine if the application is in the background using InBackgroundMode.
  • If an application needs to interact with the user while it is in the background, the solution is to display a notification (via the Notification type). The application will be brought back to the foreground when the notification is clicked, if the ActivateApplication property is set to True. You can also open a window from the procedure passed to the ActionClick property.
Component: wd290android.aar
Minimum version required
  • Version 19
Comments
Click [Add] to post a comment

Last update: 06/30/2023

Send a report | Local help