07-20-2016 05:27 AM
Oculus.Platform.Core.Initialize();
Oculus.Platform.Core.Initialize("<your app id here>");
public void CheckApplicationEntitlement() {
// Call the entitlement check function and give it the function to call when it's done
Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(IsUserEntitledToApplicationCallback);
}
void IsUserEntitledToApplicationCallback(Message msg) {
// If msg.IsError is true, then the user is not entitled to the app
if (!msg.IsError) {
mApplicationEntitled = true;
} else {
//Debug.Log("Application is NOT entitled.");
mApplicationEntitled = false;
}
}
public void RetrieveProducts() {
// Now retrieve products for the listed skus
string[] skus = { "sku 1", "sku 2", "sku 3"};
IAP.GetProductsBySKU(skus).OnComplete(GetProductsBySKUCallback);
}
void GetProductsBySKUCallback(Message msg) {
if (!msg.IsError) {
ProductList products = msg.GetProductList();
// Update the entitlements object
foreach (Product p in products) {
//Debug.Log("Product " + p.Sku + " is available for purchase for " + p.FormattedPrice + ".");
// You might want to save this sku and it's price for display somewhere else in your app. A Dictionary is a good choice for this
}
} else {
Error e = msg.GetError();
Debug.Log("GetProductsBySKUCallback Error code: " + e.Code + " http: " + e.HttpCode + " msg: " + e.Message);
}
}
public void RetrievePurchases() {
Debug.Log("Retrieve Purchases called");
IAP.GetViewerPurchases().OnComplete(GetViewerPurchasesCallback);
}
void GetViewerPurchasesCallback(Message msg) {
if (!msg.IsError) {
// Get the list of products purchased by the uer
PurchaseList purchasedProducts = msg.GetPurchaseList();
foreach (Purchase p in purchasedProducts) {
Debug.Log("Purchase " + p.Sku + " is owned by user.");
// Do something with this knowledge, perhaps by saving entitlements to a file or for updating app state
}
} else {
Error e = msg.GetError();
Debug.Log("GetViewerPurchasesCallback Error code: " + e.Code + " http: " + e.HttpCode + " msg: " + e.Message);
}
}
public void InitiatePurchase(string sku) {
// For testing within the Unity Editor, I highly recommend you short-circuit your IAP callback flow in some way that your user is simply granted access to the purchase
if (Debug.isDebugBuild) {
// Call some function to just grant the entitlement to the IAP
} else
IAP.LaunchCheckoutFlow(sku).OnComplete(LaunchCheckoutFlowCallback);
}
}
void LaunchCheckoutFlowCallback(Message msg) {
if (!msg.IsError) {
Purchase p = msg.GetPurchase();
Debug.Log("User purchased " + p.Sku + ".");
// Call your code to grant the user the IAP
} else {
Error e = msg.GetError();
Debug.Log("LaunchCheckoutFlowCallback Error code: " + e.Code + " http: " + e.HttpCode + " msg: " + e.Message);
}
}
06-05-2017 10:00 PM
06-05-2017 10:32 PM
10-27-2017 12:29 PM
06-08-2022 02:56 PM
Can you help with this error