Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate getProductsInfo() #91

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ package com.freshplanet.ane.AirInAppPurchase {

productsIds ||= [];
subscriptionIds ||= [];
_context.call("getProductsInfo", productsIds, subscriptionIds);
if (!_allStrings(productsIds) || !_allStrings(subscriptionIds)) {
_dispatchEvent(InAppPurchaseEvent.PRODUCT_INFO_ERROR, "Product and subscription IDs must all be strings");
} else {
_context.call("getProductsInfo", productsIds, subscriptionIds);
}
}
}

Expand Down Expand Up @@ -214,6 +218,17 @@ package com.freshplanet.ane.AirInAppPurchase {
_dispatchEvent(event.code, event.level);
}

/** Return true if all values in the array are strings */
private static function _allStrings(arr:Array):Boolean {

for each (var obj:Object in arr) {
if (!(obj is String)) {
return false;
}
}
return true;
}

/**
*
* @param strings
Expand Down