ionatan
12 months agoRoku Guru
getPurchases returns Unknown Error when is called before screen.show
Hello,
We are using getPurchases https://developer.roku.com/en-gb/docs/references/scenegraph/control-nodes/channelstore.md#getpurchases in order to get Subscription Purchases.
We are calling that before Channel content is loaded in order to find out if the user is a subscriber and to load content within different API parameters if that's the case.
Recently we noticed that getPurchases returns "-3: Unknown Error" status if it is called before screen.show(). In order to fix this we need to move getPurchases call after screen.show(), but if we do that the content is already loaded when Channel gets the purchases.
Did you experienced similar behaviors? Any solution for this?
This is the code used to get purchases:
store = CreateObject("roChannelStore")
port = CreateObject("roMessagePort")
store.SetMessagePort(port)
store.GetPurchases()
while (true)
msg = wait(0, port)
if (type(msg) = "roChannelStoreEvent")
if (msg.isRequestSucceeded())
for each item in msg.GetResponse()
result.validPurchased.map[item.code] = item
end for
exit while
else if (msg.isRequestFailed())
print "***** Failure: " + msg.GetStatusMessage() + " Status Code: " + stri(msg.GetStatus()) + " *****"
exit while
end if
end if
end while