Skip to content

Commit

Permalink
Merge branch 'release/1.2.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vegaro committed Jun 19, 2020
2 parents 2516c2d + 0a6bbde commit a3d1985
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 27 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 1.2.0

- Bumped iOS to 3.4.0 [Changelog here](https://github.com/RevenueCat/purchases-ios/releases)
- Bumped Android to 3.2.0 [Changelog here](https://github.com/RevenueCat/purchases-android/releases)
- Added managementURL to PurchaserInfo
- Added setProxyURL
- Added originalPurchaseDate to PurchaserInfo
- Adds new headers for platformFlavor and platformFlavorVersion
- Adds userDefaultsSuiteName as an option when setting up the SDK
- Linked TS Types (https://github.com/RevenueCat/cordova-plugin-purchases/pull/42)
- Moved iOS common files to use pod dependencies (https://github.com/RevenueCat/cordova-plugin-purchases/pull/39)
- Moved Android common files to use gradle maven dependency (https://github.com/RevenueCat/cordova-plugin-purchases/pull/39)

## 1.1.0

- Adds an example project that shows how to set up an app with RevenueCat
Expand Down
7 changes: 3 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
1. Update to the latest SDK versions in `package.json` and `plugin.xml`
1. Update version in `package.json` and `plugin.xml`.
1. Update version in `CDVPurchasesPlugin.m`.
1. Grab the `purchases-hybrid-common` .aar [from its release page](https://github.com/RevenueCat/purchases-hybrid-common/releases/) and replace it in `src/android/common-release.aar`
1. Update versions in `VERSIONS.md`
1. Update to the latest purchases-hybrid-sdk version in `plugin.xml`
1. Update version in `package.json`, `plugin.xml`, `PurchasesPlugin.java`, and `CDVPurchasesPlugin.m`.
1. Run `npm run build`
1. Add an entry to CHANGELOG.md
1. `git commit -am "Preparing for version x.y.z"`
Expand Down
1 change: 1 addition & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
| Version | iOS version | Android version | Common files version |
| ------- | ----------- | --------------- | -------------------- |
| 1.2.0 | 3.4.0 | 3.2.0 | 1.2.0 |
| 1.1.0 | 3.2.2 | 3.1.0 | 1.0.11 |
| 1.0.5 | 3.0.2 | 3.0.4 | 1.0.5 |
| 1.0.4 | 3.0.1 | 3.0.4 | 1.0.5 |
Expand Down
3 changes: 3 additions & 0 deletions examples/cordova-sample/MyApp/bin/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#! /bin/sh
cordova platform remove ios
cordova platform remove android

cordova platform add ios
cordova platform add android

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "cordova-plugin-purchases",
"version": "1.2.0-SNAPSHOT",
"version": "1.2.0",
"description": "Purchases Cordova Plugin",
"types": "./www/plugin.d.ts",
"cordova": {
"id": "cordova-plugin-purchases",
"platforms": [
Expand Down
15 changes: 10 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-purchases" version="1.2.0-SNAPSHOT">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-purchases" version="1.2.0">

<dependency id="cordova-annotated-plugin-android" />

Expand All @@ -16,8 +16,7 @@
<param name="android-package" value="com.revenuecat.purchases.PurchasesPlugin" />
</feature>
</config-file>
<framework src="com.revenuecat.purchases:purchases:3.1.0" />
<framework src="com.revenuecat.purchases:purchases-hybrid-common:1.1.2" />
<framework src="com.revenuecat.purchases:purchases-hybrid-common:1.2.0" />
<source-file src="src/android/PurchasesPlugin.java" target-dir="src/com/revenuecat/purchases"/>
</platform>
<platform name="ios">
Expand All @@ -28,7 +27,13 @@
</config-file>
<header-file src="src/ios/CDVPurchasesPlugin.h" />
<source-file src="src/ios/CDVPurchasesPlugin.m" />
<framework src="Purchases" type="podspec" spec="3.3.1" />
<framework src="PurchasesHybridCommon" type="podspec" spec="1.1.0" />
<podspec>
<config>
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="PurchasesHybridCommon" spec="1.2.0" />
</pods>
</podspec>
</platform>
</plugin>
12 changes: 9 additions & 3 deletions src/android/PurchasesPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
public class PurchasesPlugin extends AnnotatedCordovaPlugin {

public static final String PLATFORM_NAME = "cordova";
public static final String PLUGIN_VERSION = "1.2.0-SNAPSHOT";
public static final String PLUGIN_VERSION = "1.2.0";

@PluginAction(thread = ExecutionThread.MAIN, actionName = "setupPurchases", isAutofinish = false)
private void setupPurchases(String apiKey, String appUserID, boolean observerMode,
CallbackContext callbackContext) {
private void setupPurchases(String apiKey, @Nullable String appUserID, boolean observerMode,
@Nullable String userDefaultsSuiteName, CallbackContext callbackContext) {
PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
CommonKt.configure(this.cordova.getActivity(), apiKey, appUserID, observerMode, platformInfo);
Purchases.getSharedInstance().setUpdatedPurchaserInfoListener(purchaserInfo -> {
Expand Down Expand Up @@ -195,6 +195,12 @@ private void invalidatePurchaserInfoCache(CallbackContext callbackContext) {
CommonKt.invalidatePurchaserInfoCache();
callbackContext.success();
}

@PluginAction(thread = ExecutionThread.MAIN, actionName = "setProxyURLString")
public void setProxyURLString(String proxyURLString, CallbackContext callbackContext) {
CommonKt.setProxyURLString(proxyURLString);
callbackContext.success();
}

//================================================================================
// Subscriber Attributes
Expand Down
11 changes: 6 additions & 5 deletions src/ios/CDVPurchasesPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
- (void)isAnonymous:(CDVInvokedUrlCommand *)command;
- (void)checkTrialOrIntroductoryPriceEligibility:(CDVInvokedUrlCommand *)command;
- (void)invalidatePurchaserInfoCache:(CDVInvokedUrlCommand *)command;
- (void)setAttributes:(NSDictionary<NSString *, NSString *> *)attributes;
- (void)setEmail:(nullable NSString *)email;
- (void)setPhoneNumber:(nullable NSString *)phoneNumber;
- (void)setDisplayName:(nullable NSString *)displayName;
- (void)setPushToken:(nullable NSData *)pushToken;
- (void)setAttributes:(CDVInvokedUrlCommand *)command;
- (void)setEmail:(CDVInvokedUrlCommand *)command;
- (void)setPhoneNumber:(CDVInvokedUrlCommand *)command;
- (void)setDisplayName:(CDVInvokedUrlCommand *)command;
- (void)setPushToken:(CDVInvokedUrlCommand *)command;
- (void)setProxyURLString:(CDVInvokedUrlCommand *)command;

@end
11 changes: 9 additions & 2 deletions src/ios/CDVPurchasesPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ - (void)setupPurchases:(CDVInvokedUrlCommand *)command
NSString *apiKey = [command argumentAtIndex:0];
NSString *appUserID = [command argumentAtIndex:1];
BOOL observerMode = [[command argumentAtIndex:2] boolValue];
NSString *userDefaultsSuiteName = [command argumentAtIndex:3];

[RCPurchases configureWithAPIKey:apiKey
appUserID:appUserID
observerMode:observerMode
userDefaults:nil
userDefaultsSuiteName:userDefaultsSuiteName
platformFlavor:self.platformFlavor
platformFlavorVersion:self.platformFlavorVersion];
RCPurchases.sharedPurchases.delegate = self;
Expand Down Expand Up @@ -176,6 +177,12 @@ - (void)invalidatePurchaserInfoCache:(CDVInvokedUrlCommand *)command {
[self sendOKForCommand:command messageAsArray:nil];
}

- (void)setProxyURLString:(CDVInvokedUrlCommand *)command {
NSString *proxyURLString = [command argumentAtIndex:0];
[RCCommonFunctionality setProxyURLString:proxyURLString];
[self sendOKForCommand:command messageAsArray:nil];
}

#pragma mark Subscriber Attributes

- (void)setAttributes:(CDVInvokedUrlCommand *)command {
Expand Down Expand Up @@ -263,7 +270,7 @@ - (NSString *)platformFlavor {
}

- (NSString *)platformFlavorVersion {
return @"1.1.0";
return @"1.2.0";
}

@end
33 changes: 31 additions & 2 deletions src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ export interface PurchaserInfo {
* in Android
*/
readonly originalApplicationVersion: string | null;
/**
* Returns the purchase date for the version of the application when the user bought the app.
* Use this for grandfathering users when migrating to subscriptions.
*/
readonly originalPurchaseDate: string | null;
/**
* URL to manage the active subscription of the user. If this user has an active iOS
* subscription, this will point to the App Store, if the user has an active Play Store subscription
* it will point there. If there are no active subscriptions it will be null.
* If there are multiple for different platforms, it will point to the device store.
*/
readonly managementURL: string | null;
}

export interface PurchasesProduct {
Expand Down Expand Up @@ -470,11 +482,15 @@ class Purchases {
* @param {boolean} observerMode An optional boolean. Set this to TRUE if you have your own IAP implementation and
* want to use only RevenueCat's backend. Default is FALSE. If you are on Android and setting this to ON, you will have
* to acknowledge the purchases yourself.
* @param {string?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults
* suite, otherwise it will use standardUserDefaults. Default is null, which will make the SDK use standardUserDefaults.
*/
public static setup(
apiKey: string,
appUserID?: string | null,
observerMode: boolean = false
observerMode: boolean = false,
userDefaultsSuiteName?: string
) {
window.cordova.exec(
(purchaserInfo: any) => {
Expand All @@ -483,7 +499,7 @@ class Purchases {
null,
PLUGIN_NAME,
"setupPurchases",
[apiKey, appUserID, observerMode]
[apiKey, appUserID, observerMode, userDefaultsSuiteName]
);
this.setupShouldPurchasePromoProductCallback();
}
Expand Down Expand Up @@ -977,6 +993,19 @@ class Purchases {
);
}

/**
* Set this property to your proxy URL before configuring Purchases *only* if you've received a proxy key value from your RevenueCat contact.
* @param url Proxy URL as a string.
*/
public static setProxyURL(url: string) {
window.cordova.exec(
null,
null,
PLUGIN_NAME,
"setProxyURLString",
[url]
);
}

private static setupShouldPurchasePromoProductCallback() {
window.cordova.exec(
Expand Down
42 changes: 41 additions & 1 deletion tests/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,47 @@ describe("Purchases", () => {
null,
"PurchasesPlugin",
"setupPurchases",
["api_key", "app_user_id", false]
["api_key", "app_user_id", false, undefined]
);
});

it("setup fires PurchasesPlugin with the correct arguments when specifying observermode", () => {
Purchases.setup("api_key", "app_user_id", true);

expect(execFn).toHaveBeenCalledWith(
expect.any(Function),
null,
"PurchasesPlugin",
"setupPurchases",
["api_key", "app_user_id", true, undefined]
);
});

it("setup fires PurchasesPlugin with the correct arguments when setting user defaults suite name", () => {
const expected = "suite-name";

Purchases.setup("api_key", "app_user_id", false, expected);

expect(execFn).toHaveBeenCalledWith(
expect.any(Function),
null,
"PurchasesPlugin",
"setupPurchases",
["api_key", "app_user_id", false, expected]
);
});

it("setProxyURL fires PurchasesPlugin with the correct arguments", () => {
const expected = "https://proxy.com";
Purchases.setProxyURL(expected);

expect(execFn).toHaveBeenCalledWith(
null,
null,
"PurchasesPlugin",
"setProxyURLString",
[expected]
);
});

});
22 changes: 21 additions & 1 deletion www/plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@ export interface PurchaserInfo {
* in Android
*/
readonly originalApplicationVersion: string | null;
/**
* Returns the purchase date for the version of the application when the user bought the app.
* Use this for grandfathering users when migrating to subscriptions.
*/
readonly originalPurchaseDate: string | null;
/**
* URL to manage the active subscription of the user. If this user has an active iOS
* subscription, this will point to the App Store, if the user has an active Play Store subscription
* it will point there. If there are no active subscriptions it will be null.
* If there are multiple for different platforms, it will point to the device store.
*/
readonly managementURL: string | null;
}
export interface PurchasesProduct {
/**
Expand Down Expand Up @@ -440,8 +452,11 @@ declare class Purchases {
* @param {boolean} observerMode An optional boolean. Set this to TRUE if you have your own IAP implementation and
* want to use only RevenueCat's backend. Default is FALSE. If you are on Android and setting this to ON, you will have
* to acknowledge the purchases yourself.
* @param {string?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults
* suite, otherwise it will use standardUserDefaults. Default is null, which will make the SDK use standardUserDefaults.
*/
static setup(apiKey: string, appUserID?: string | null, observerMode?: boolean): void;
static setup(apiKey: string, appUserID?: string | null, observerMode?: boolean, userDefaultsSuiteName?: string): void;
/**
* Set this to true if you are passing in an appUserID but it is anonymous, this is true by default if you didn't pass an appUserID
* If a user tries to purchase a product that is active on the current app store account, we will treat it as a restore and alias
Expand Down Expand Up @@ -672,6 +687,11 @@ declare class Purchases {
* @param pushToken null will delete the subscriber attribute.
*/
static setPushToken(pushToken: string | null): void;
/**
* Set this property to your proxy URL before configuring Purchases *only* if you've received a proxy key value from your RevenueCat contact.
* @param url Proxy URL as a string.
*/
static setProxyURL(url: string): void;
private static setupShouldPurchasePromoProductCallback;
private static getMakeDeferredPurchaseFunction;
}
Expand Down
14 changes: 12 additions & 2 deletions www/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ var Purchases = /** @class */ (function () {
* @param {boolean} observerMode An optional boolean. Set this to TRUE if you have your own IAP implementation and
* want to use only RevenueCat's backend. Default is FALSE. If you are on Android and setting this to ON, you will have
* to acknowledge the purchases yourself.
* @param {string?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults
* suite, otherwise it will use standardUserDefaults. Default is null, which will make the SDK use standardUserDefaults.
*/
Purchases.setup = function (apiKey, appUserID, observerMode) {
Purchases.setup = function (apiKey, appUserID, observerMode, userDefaultsSuiteName) {
if (observerMode === void 0) { observerMode = false; }
window.cordova.exec(function (purchaserInfo) {
window.cordova.fireWindowEvent("onPurchaserInfoUpdated", purchaserInfo);
}, null, PLUGIN_NAME, "setupPurchases", [apiKey, appUserID, observerMode]);
}, null, PLUGIN_NAME, "setupPurchases", [apiKey, appUserID, observerMode, userDefaultsSuiteName]);
this.setupShouldPurchasePromoProductCallback();
};
/**
Expand Down Expand Up @@ -452,6 +455,13 @@ var Purchases = /** @class */ (function () {
Purchases.setPushToken = function (pushToken) {
window.cordova.exec(null, null, PLUGIN_NAME, "setPushToken", [pushToken]);
};
/**
* Set this property to your proxy URL before configuring Purchases *only* if you've received a proxy key value from your RevenueCat contact.
* @param url Proxy URL as a string.
*/
Purchases.setProxyURL = function (url) {
window.cordova.exec(null, null, PLUGIN_NAME, "setProxyURLString", [url]);
};
Purchases.setupShouldPurchasePromoProductCallback = function () {
var _this = this;
window.cordova.exec(function (_a) {
Expand Down

0 comments on commit a3d1985

Please sign in to comment.