const IOnlineSubsystem* OnlineSub = Online::GetSubsystem(GetWorld(), OCULUS_SUBSYSTEM);<br> check(OnlineSub);<br><br> const FOnlineSubsystemOculus* OculusSubsystem = static_cast<const FOnlineSubsystemOculus*>(OnlineSub);<br> check(OculusSubsystem);<br><br> UE_LOG_VR(Verbose, TEXT("Attempting to buy %d coins with SKU '%s'"), Amount, *SKU);<br> const char* c_sku = TCHAR_TO_ANSI(*SKU);<br> <br> OculusSubsystem->AddRequestDelegate(<br> ovr_IAP_LaunchCheckoutFlow(c_sku), <br> FOculusMessageOnCompleteDelegate::CreateLambda([this, c_sku, Amount](ovrMessageHandle Message, bool bIsError)<br> {<br> if (bIsError)<br> {<br> UE_LOG_VR(Error, TEXT("Purchase Error of %s"), c_sku);<br> }<br> else<br> {<br> ovrPurchaseHandle Handle = ovr_Message_GetPurchase(Message);<br> ovrID ID = ovr_Purchase_GetPurchaseID(Handle);<br> UE_LOG_VR(Verbose, TEXT("Purchase Success (%llu)"), ID);<br><br> ovr_IAP_ConsumePurchase(c_sku);<br> }
Answers
An extension question, do we need to initialize the subsystem like Oculus instruct on their website of the OVR_Platform SDK?
https://developer.oculus.com/documentation/unreal/ps-setup/
Now I'm trying to purchase a item (the SKU is "TestItem") combining your code and the Oculus example.
However, when I ran this code, it crashed the app and jump back to home screen. But there was one time, it did pop out the Checkout page and asked if I want to purchase this item.
I have another button to make sure that the OSS is initiated before I can ran the following purchase code. The initialization status was shown on the screen so I knew it's done.
Would you please check if there is something incorrect in the code?
p.s. The item was also created on the Oculus Dashboard already.
What are the chances for you guys to expose all IAP functionality to Blueprints, in the nearest future (like, for UE 4.26 release) ?
Yeah, I am a solo dev and my project is all BP. It's critical for me to be able to do everything in BP and Platform SDK, sadly, is all C++ as far as I can tell. I can never get straight answer from Oculus about them exposing Platform SDK stuff to BP
My target platform is Oculus Go, and I can only test it by uploading to the store and then download it from my Go. Otherwise the entitlement check will fail. I've also checked many times of the code logic and couldn't think of anything. Maybe I should try the Android Studio for debugging.
Thanks a lot for your advice.
I used the Android device monitor to log when I triggered the crash. Here is the Assert level of log and I don't know maybe you can help me find some clues what exactly led to the crash. I've attached it as text file in the attachment.
I think I successfully did the checkout of IAP. It was the part I used a string instead of a const char* as the argument for the checkout function. But it works now.
However, I can't consume this purchased consumable item because after I jumped to that Oculus purchase screen, my app already stopped. So I suppose the function to consume the item can't be reached.
Have you encountered similar problem before?
You can see from my purchase success path that I call ovr_IAP_ConsumePurchase within the lambda that resumes once the Oculus purchase UI returns control to my app. I haven't encountered the problem you describe, perhaps add some logging before and after the points were the Purchase UI is invoked and see if it resumes properly?
dont have much experience debugging for android devices