Skip to content

Commit

Permalink
fix: null fields with android sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
kherembourg committed Feb 9, 2022
1 parent 500d772 commit 6670175
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
1 change: 1 addition & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ This file provides the underlying native SDK versions that the Cordova SDK relie
| 1.1.7 | 2.7.3 | 2.7.4 |
| 1.1.8 | 2.7.3 | 2.7.6 |
| 1.2.0 | 2.8.0 | 2.8.0 |
| 1.2.1 | 2.8.0 | 2.8.0 |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purchasely/cordova-plugin-purchasely",
"version": "1.2.0",
"version": "1.2.1",
"description": "Purchasely is a solution to ease the integration and boost your In-App Purchases & Subscriptions on the App Store, Google Play Store, Amazon Appstore and Huawei App Gallery.",
"cordova": {
"id": "@purchasely/cordova-plugin-purchasely",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="@purchasely/cordova-plugin-purchasely" version="1.2.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="@purchasely/cordova-plugin-purchasely" version="1.2.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>Purchasely</name>
<js-module name="Purchasely" src="www/Purchasely.js">
<clobbers target="Purchasely" />
Expand Down
44 changes: 26 additions & 18 deletions src/android/PurchaselyPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
switch (action) {
case "startWithAPIKey":
startWithAPIKey(
args.getString(0),
getStringFromJson(args.getString(0)),
args.getJSONArray(1),
args.getString(2),
getStringFromJson(args.getString(2)),
args.getInt(3),
args.getBoolean(4),
callbackContext);
Expand All @@ -81,19 +81,19 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
getAnonymousUserId(callbackContext);
break;
case "userLogin":
userLogin(args.getString(0), callbackContext);
userLogin(getStringFromJson(args.getString(0)), callbackContext);
break;
case "userLogout":
userLogout();
break;
case "setLanguage":
setLanguage(args.getString(0));
setLanguage(getStringFromJson(args.getString(0)));
break;
case "setLogLevel":
setLogLevel(args.getInt(0));
break;
case "setAttribute":
setAttribute(args.getInt(0), args.getString(1));
setAttribute(args.getInt(0), getStringFromJson(args.getString(1)));
break;
case "setDefaultPresentationResultHandler":
setDefaultPresentationResultHandler(callbackContext);
Expand All @@ -109,24 +109,24 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
break;
case "presentPresentationWithIdentifier":
presentPresentationWithIdentifier(
args.getString(0),
args.getString(1),
getStringFromJson(args.getString(0)),
getStringFromJson(args.getString(1)),
callbackContext
);
break;
case "presentProductWithIdentifier":
presentProductWithIdentifier(
args.getString(0),
args.getString(1),
args.getString(2),
getStringFromJson(args.getString(0)),
getStringFromJson(args.getString(1)),
getStringFromJson(args.getString(2)),
callbackContext
);
break;
case "presentPlanWithIdentifier":
presentPlanWithIdentifier(
args.getString(0),
args.getString(1),
args.getString(2),
getStringFromJson(args.getString(0)),
getStringFromJson(args.getString(1)),
getStringFromJson(args.getString(2)),
callbackContext
);
break;
Expand All @@ -143,21 +143,21 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
userSubscriptions(callbackContext);
break;
case "handle":
handle(args.getString(0), callbackContext);
handle(getStringFromJson(args.getString(0)), callbackContext);
break;
case "allProducts":
allProducts(callbackContext);
break;
case "productWithIdentifier":
productWithIdentifier(args.getString(0), callbackContext);
productWithIdentifier(getStringFromJson(args.getString(0)), callbackContext);
break;
case "planWithIdentifier":
planWithIdentifier(args.getString(0), callbackContext);
planWithIdentifier(getStringFromJson(args.getString(0)), callbackContext);
break;
case "purchaseWithPlanVendorId":
purchaseWithPlanVendorId(
args.getString(0),
args.getString(1),
getStringFromJson(args.getString(0)),
getStringFromJson(args.getString(1)),
callbackContext
);
break;
Expand All @@ -183,6 +183,14 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
return true;
}

private String getStringFromJson(String value) {
if(value == null || value.equals("null") || value.isEmpty()) {
return null;
}

return value;
}

public static void sendPurchaseResult(PLYProductViewResult result, PLYPlan plan) {
int productViewResult = 0;
if(result == PLYProductViewResult.PURCHASED) {
Expand Down

0 comments on commit 6670175

Please sign in to comment.