iOS Question InApp RequestProductsInformation question

Markos

Well-Known Member
Licensed User
Longtime User
Hi All,

I want to use the RequestProductsInformation method to allow changes in the product listing I define for InApp purchases to be seamless i n the iOS App. I am encountering an issue of the Type StoreProduct and Product as not defined. I thought it was owing to the fact that I was using v8.5 so I upgraded as I should do anyway to v10x to get the latest iStore. This still could not find the StoreProduct struct type. The code sample is shown below..

B4X:
Sub Process_Globals
 Public Store1 As Store
End Sub

Sub GetProductDetails
    Store1.RequestProductsInformation(productIDs)
End Sub

Sub Store1_ProductDetails (Success As Boolean, Products As Map)
    productlist.Clear
    productbuy.Clear
    If Success Then
        If Products.ContainsKey("com.progwhiz.someapp") Then
            For Each prd As StoreProduct In Products ' The error not finding StoreProduct happens here
                productlist.Add(prd.productid)
                'Log("Product Name: " & prd.Title)
                'Log("Product Price: " & prd.FormattedPrice)
            Next
        End If
    Else
        Log("Failed to connect to App Store")
    End If
End Sub

I initiate the call to GetProductDetails to trigger the events

Online I only see reference to the method RequestProductData but this does not exist in the Store object

If I am to simply use the ProductID's I created and explicitly call without using RequestProductsInformation then so be it but please advice
 
Last edited:

Markos

Well-Known Member
Licensed User
Longtime User
Hi All,

I want to use the RequestProductsInformation method to allow changes in the product listing I define for InApp purchases to be seamless i n the iOS App. I am encountering an issue of the Type StoreProduct and Product as not defined. I thought it was owing to the fact that I was using v8.5 so I upgraded as I should do anyway to v10x to get the latest iStore. This still could not find the StoreProduct struct type. The code sample is shown below..

B4X:
Sub Process_Globals
 Public Store1 As Store
End Sub

Sub GetProductDetails
    Store1.RequestProductsInformation(productIDs)
End Sub

Sub Store1_ProductDetails (Success As Boolean, Products As Map)
    productlist.Clear
    productbuy.Clear
    If Success Then
        If Products.ContainsKey("com.progwhiz.someapp") Then
            For Each prd As StoreProduct In Products ' The error not finding StoreProduct happens here
                productlist.Add(prd.productid)
                'Log("Product Name: " & prd.Title)
                'Log("Product Price: " & prd.FormattedPrice)
            Next
        End If
    Else
        Log("Failed to connect to App Store")
    End If
End Sub

I initiate the call to GetProductDetails to trigger the events

Online I only see reference to the method RequestProductData but this does not exist in the Store object

If I am to simply use the ProductID's I created and explicitly call without using RequestProductsInformation then so be it but please advice
Ok I found the answer I hope in 2 parts
1. Use InformationAvailable as the event name for the method RequestProductsInformation
2. Use ProductInformation instead of StoreProduct

Resulting in the following code for the Event

B4X:
Sub Store1_InformationAvailable (Success As Boolean, Products As Map)
    productlist.Clear
    productbuy.Clear
    If Success Then
        If Products.ContainsKey("com.progwhiz.someapp") Then
            For Each prd As ProductInformation  In Products
                Log("Product Name: " & prd.Title)
                Log("Product Price: " & prd.LocalizedPrice)
            Next
        End If
    Else
        Log("Failed to connect to App Store")
    End If
End Sub
 
Last edited:
Upvote 0

Markos

Well-Known Member
Licensed User
Longtime User
I keep on coming up with questions and answering myself lol. Last query..

is the if clause using Products.ContainsKey an obsolete and redundant as the RequestProductsInformation method is calling with a list of productid's and the event returns the Products as a Map so not only is it not necessary but you have to assume the keys are aka as productid and it adds no value checking productid's unless one last check to ensure at least one productid as a key is in the Products Map?
 
Upvote 0

Markos

Well-Known Member
Licensed User
Longtime User
1. Nothing bad with this check. Performance-wise it has zero impact.
2. If you are calling RequestProductsInformation with a single id, and Success = True, then you don't really need this check as the product id will be there.
Agreed in principal if the Success=True once at least one key/productID is found from the Products map returned then it is relevant to check only productid/keys desired are presented.

Is it then safe to conclude the Key's found would be equivalient to the productID's? for example:

two(2) product ID's (com.myapp.product1 and (com.myapp.product2) passed as a list to RequestProductsInformation and the if clause would be inside the For Each loop and would need to be as follows to negate any productid's not relevant:

B4X:
if Products.ContainsKey("com.myapp.product1")  or Products.ContainsKey("com.myapp.product2") then
 
Last edited:
Upvote 0
Top