6 Commits
1.2.3 ... 1.3.0

Author SHA1 Message Date
Björn Ritzl
f1d53948e9 Merge pull request #20 from defold/Issue-18-crash-on-empty-product
Check if title or description is null
2020-03-09 12:33:48 +01:00
Björn Ritzl
607b4a117e Update iap_ios.mm 2020-03-09 11:57:14 +01:00
Björn Ritzl
38656e973c Check if title or description is null
Fixes #18
2020-03-09 11:46:01 +01:00
Björn Ritzl
4efe0c2a25 Merge pull request #19 from defold/Issue-3-handle-missing-google-play-store
Handle missing google play store
2020-03-09 11:43:28 +01:00
Björn Ritzl
3fb09c3b95 Missing import 2020-03-09 11:22:54 +01:00
Björn Ritzl
2843080690 Check that the Google Play Store exists on device
Fixes #3
2020-03-09 11:22:41 +01:00
4 changed files with 31 additions and 3 deletions

View File

@@ -119,8 +119,20 @@ static void IAP_FreeTransaction(IAPTransaction* transaction)
IAPProduct product = {0};
product.ident = strdup([p.productIdentifier UTF8String]);
product.title = strdup([p.localizedTitle UTF8String]);
product.description = strdup([p.localizedDescription UTF8String]);
if (p.localizedTitle) {
product.title = strdup([p.localizedTitle UTF8String]);
}
else {
dmLogWarning("Product %s has no localizedTitle", [p.productIdentifier UTF8String]);
product.title = "";
}
if (p.localizedDescription) {
product.description = strdup([p.localizedDescription UTF8String]);
}
else {
dmLogWarning("Product %s has no localizedDescription", [p.productIdentifier UTF8String]);
product.description = "";
}
product.currency_code = strdup([[p.priceLocale objectForKey:NSLocaleCurrencyCode] UTF8String]);
product.price = p.price.floatValue;

View File

@@ -17,6 +17,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -155,10 +156,24 @@ public class IapGooglePlay implements Handler.Callback {
this.autoFinishTransactions = autoFinishTransactions;
}
private static boolean isPlayStoreInstalled(Context context){
try {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
private void init() {
// NOTE: We must create Handler lazily as construction of
// handlers must be in the context of a "looper" on Android
if (!isPlayStoreInstalled(activity)) {
Log.e(TAG, "Unable to find Google Play Store (com.android.vending)");
return;
}
if (this.initialized)
return;

View File

@@ -11,7 +11,7 @@ height = 1136
[android]
input_method = HiddenInputField
package = com.defold.extension.iap
version_code = 3
version_code = 5
[project]
title = extension-iap

View File

@@ -12,6 +12,7 @@ local items = {
SUBSCRIPTION,
}
-- mapping between product id and button name
local item_buttons = {
[GOLDBARS_SMALL] = "goldbars_small",
[GOLDBARS_MEDIUM] = "goldbars_medium",