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

Google Play Billing Library 6 support #54

Merged
merged 6 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<js-module src="www/Offering.js" name="Offering" />
<js-module src="www/Offerings.js" name="Offerings" />
<js-module src="www/Product.js" name="Product" />
<js-module src="www/ProductInAppDetails.js" name="ProductInAppDetails" />
<js-module src="www/ProductOfferDetails.js" name="ProductOfferDetails" />
<js-module src="www/ProductPrice.js" name="ProductPrice" />
<js-module src="www/ProductPricingPhase.js" name="ProductPricingPhase" />
<js-module src="www/ProductStoreDetails.js" name="ProductStoreDetails" />
<js-module src="www/PurchaseModel.js" name="PurchaseModel" />
<js-module src="www/PurchaseUpdateModel.js" name="PurchaseUpdateModel" />
<js-module src="www/Experiment.js" name="Experiment" />
<js-module src="www/ExperimentGroup.js" name="ExperimentGroup" />
<js-module src="www/RemoteConfig.js" name="RemoteConfig" />
Expand All @@ -38,14 +45,15 @@
<js-module src="www/SKProductDiscount.js" name="SKProductDiscount" />
<js-module src="www/SKSubscriptionPeriod.js" name="SKSubscriptionPeriod" />
<js-module src="www/SkuDetails.js" name="SkuDetails" />
<js-module src="www/SubscriptionPeriod.js" name="SubscriptionPeriod" />

<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="QonversionPlugin" >
<param name="android-package" value="com.qonversion.android.sdk.QonversionPlugin"/>
</feature>
</config-file>
<framework src="io.qonversion.sandwich:sandwich:3.3.3" />
<framework src="io.qonversion.sandwich:sandwich:4.0.0" />
<source-file src="src/android/QonversionPlugin.java" target-dir="src/com/qonversion/android/sdk" />
<source-file src="src/android/EntitiesConverter.java" target-dir="src/com/qonversion/android/sdk" />
<source-file src="src/android/Utils.java" target-dir="src/com/qonversion/android/sdk" />
Expand All @@ -63,7 +71,7 @@
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="QonversionSandwich" spec="3.3.3" />
<pod name="QonversionSandwich" spec="4.0.0" />
</pods>
</podspec>
</platform>
Expand Down
49 changes: 13 additions & 36 deletions plugin/src/android/QonversionPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,53 +82,30 @@ public void initializeSdk(
entitlementsUpdateCallbackContext.sendPluginResult(result);
}

@PluginAction(thread = ExecutionThread.UI, actionName = "purchaseProduct", isAutofinish = false)
public void purchaseProduct(String productId, String offeringId, CallbackContext callbackContext) {
qonversionSandwich.purchaseProduct(productId, offeringId, getPurchaseResultListener(callbackContext));
}

@PluginAction(thread = ExecutionThread.UI, actionName = "purchase", isAutofinish = false)
public void purchase(String productId, CallbackContext callbackContext) {
qonversionSandwich.purchase(productId, getPurchaseResultListener(callbackContext));
}

@PluginAction(thread = ExecutionThread.UI, actionName = "updateProductWithId", isAutofinish = false)
public void updateProductWithId(
final String productId,
@Nullable final String offeringId,
final String oldProductId,
CallbackContext callbackContext
) {
updateProductWithIdAndProrationMode(productId, offeringId, oldProductId, null, callbackContext);
public void purchase(String productId, @Nullable String offerId, @Nullable Boolean applyOffer, CallbackContext callbackContext) {
qonversionSandwich.purchase(productId, offerId, applyOffer, getPurchaseResultListener(callbackContext));
}

@PluginAction(thread = ExecutionThread.UI, actionName = "updateProductWithIdAndProrationMode", isAutofinish = false)
public void updateProductWithIdAndProrationMode(
final String productId,
@Nullable final String offeringId,
final String oldProductId,
@Nullable final Integer prorationMode,
@PluginAction(thread = ExecutionThread.UI, actionName = "updatePurchase", isAutofinish = false)
public void updatePurchase(
String productId,
@Nullable String offerId,
@Nullable Boolean applyOffer,
String oldProductId,
@Nullable String updatePolicyKey,
CallbackContext callbackContext
) {
qonversionSandwich.updatePurchaseWithProduct(
qonversionSandwich.updatePurchase(
productId,
offeringId,
offerId,
applyOffer,
oldProductId,
prorationMode,
updatePolicyKey,
getPurchaseResultListener(callbackContext)
);
}

@PluginAction(thread = ExecutionThread.UI, actionName = "updatePurchase", isAutofinish = false)
public void updatePurchase(String productId, String oldProductId, CallbackContext callbackContext) {
updatePurchaseWithProrationMode(productId, oldProductId, null, callbackContext);
}

@PluginAction(thread = ExecutionThread.UI, actionName = "updatePurchaseWithProrationMode", isAutofinish = false)
public void updatePurchaseWithProrationMode(String productId, String oldProductId, Integer prorationMode, CallbackContext callbackContext) {
qonversionSandwich.updatePurchase(productId, oldProductId, prorationMode, getPurchaseResultListener(callbackContext));
}

@PluginAction(thread = ExecutionThread.WORKER, actionName = "setDefinedProperty")
public void setDefinedProperty(String key, String value, CallbackContext callbackContext) {
qonversionSandwich.setDefinedProperty(key, value);
Expand Down
1 change: 0 additions & 1 deletion plugin/src/ios/CDVQonversionPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)userProperties:(CDVInvokedUrlCommand *)command;
- (void)attribution:(CDVInvokedUrlCommand *)command;
- (void)checkEntitlements:(CDVInvokedUrlCommand *)command;
- (void)purchaseProduct:(CDVInvokedUrlCommand *)command;
- (void)purchase:(CDVInvokedUrlCommand *)command;
- (void)products:(CDVInvokedUrlCommand *)command;
- (void)restore:(CDVInvokedUrlCommand *)command;
Expand Down
9 changes: 0 additions & 9 deletions plugin/src/ios/CDVQonversionPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ - (void)checkEntitlements:(CDVInvokedUrlCommand *)command {
}];
}

- (void)purchaseProduct:(CDVInvokedUrlCommand *)command {
NSString *productId = [command argumentAtIndex:0];
NSString *offeringId = [command argumentAtIndex:1];
__block __weak CDVQonversionPlugin *weakSelf = self;
[self.qonversionSandwich purchaseProduct:productId offeringId:offeringId completion:^(NSDictionary<NSString *,id> * _Nullable result, SandwichError * _Nullable error) {
[weakSelf returnCordovaResult:result error:error command:command];
}];
}

- (void)purchase:(CDVInvokedUrlCommand *)command {
NSString *productId = [command argumentAtIndex:0];
__block __weak CDVQonversionPlugin *weakSelf = self;
Expand Down
Loading