How to validate if a user has an active subscription
How to validate if a user has an active subscription
BY 17 Oct 2019Web Application Development
Edit: This is for a Wearable project. (Samsung Gear S3 & Samsung Galaxy Watch)
Hi, I’m trying to check if the user has an active subsription. I tried the following but it doesn’t appear to be working.
var fetchSubscriptions = function() {
// Request the available item list
webapis.inapppurchase.getItemList(1, 15, "ALL", "IAP_COMMERCIAL_MODE", checkPurchases, failedSubscription);
}
var checkPurchases = function(purchases) {
// Find the highest expiry timestamp of all purchases
var highestTimestamp = 0;
// Loop through all purchases
for (var i = 0; i < purchases._items.length; i++) {
// Turn expiry date into a timestamp
var endDateString = purchases._items[i].mSubscriptionEndDate;
var endDateTimestamp = new Date(endDateString).getTime();
// Check if this timestamp is higher than the previous highest
if(highestTimestamp > endDateTimestamp) {
// Replace highest with new highest timestamp
highestTimestamp = endDateTimestamp;
}
}
// If the highest timestamp is higher than today
var today = new Date().getTime();
if(highestTimestamp > today) {
// User is subscribed
} else {
// User is NOT subscribed
}
}
var failedSubscription = function() {
// Show some error
}
How am I supposed to check subscription validity and does this method gives “not subscribed” in case the user cancelled his/her subscription?
Since the last Tizen update IAP is no longer working on my Watch & Phone (which I’m already in contact for with the Samsung Developers), in the meantime it makes testing IAP features extremely hard.
How to validate if a user has an active subscription
Edit: This is for a Wearable project. (Samsung Gear S3 & Samsung Galaxy Watch)
Hi, I’m trying to check if the user has an active subsription. I tried the following but it doesn’t appear to be working.
How am I supposed to check subscription validity and does this method gives “not subscribed” in case the user cancelled his/her subscription?
Since the last Tizen update IAP is no longer working on my Watch & Phone (which I’m already in contact for with the Samsung Developers), in the meantime it makes testing IAP features extremely hard.
BY
16 Apr 2025
Tizen Studio
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio