@purchasely/cordova-plugin-purchasely 4.3.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,8 +15,8 @@
15
15
  "devDependencies": {
16
16
  "@purchasely/cordova-plugin-puchasely-google": "file:../../purchasely-google",
17
17
  "@purchasely/cordova-plugin-purchasely": "file:..",
18
- "cordova-android": "^12.0.1",
19
- "cordova-ios": "^7.0.1",
18
+ "cordova-android": "^13.0.0",
19
+ "cordova-ios": "^7.1.0",
20
20
  "cordova-plugin-puchasely-google": "file:../../purchasely-google",
21
21
  "cordova-plugin-purchasely": "file:.."
22
22
  },
@@ -26,8 +26,7 @@
26
26
  "@purchasely/cordova-plugin-purchasely": {}
27
27
  },
28
28
  "platforms": [
29
- "android",
30
- "ios"
29
+ "android"
31
30
  ]
32
31
  }
33
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purchasely/cordova-plugin-purchasely",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "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.",
5
5
  "cordova": {
6
6
  "id": "@purchasely/cordova-plugin-purchasely",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="@purchasely/cordova-plugin-purchasely" version="4.3.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin id="@purchasely/cordova-plugin-purchasely" version="4.4.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
3
  <name>Purchasely</name>
4
4
  <js-module name="Purchasely" src="www/Purchasely.js">
5
5
  <clobbers target="Purchasely" />
@@ -36,7 +36,7 @@
36
36
  <source url="https://github.com/CocoaPods/Specs.git"/>
37
37
  </config>
38
38
  <pods use-frameworks="true">
39
- <pod name="Purchasely" spec="4.3.4"/>
39
+ <pod name="Purchasely" spec="4.4.2"/>
40
40
  </pods>
41
41
  </podspec>
42
42
  </platform>
@@ -61,7 +61,7 @@
61
61
  android:theme="@style/Theme.AppCompat.Light.NoActionBar">
62
62
  </activity>
63
63
  </config-file>
64
- <framework src="io.purchasely:core:4.3.4" />
64
+ <framework src="io.purchasely:core:4.4.2" />
65
65
  <source-file src="src/android/PurchaselyPlugin.kt" target-dir="java/cordova/plugin/purchasely" />
66
66
  <source-file src="src/android/PLYProductActivity.kt" target-dir="java/cordova/plugin/purchasely" />
67
67
  <source-file src="src/android/PLYSubscriptionsActivity.java" target-dir="src/cordova/plugin/purchasely" />
@@ -131,11 +131,6 @@ class PLYProductActivity : AppCompatActivity() {
131
131
  PurchaselyPlugin.productActivity = productActivity
132
132
  }
133
133
 
134
- override fun onDestroy() {
135
- PurchaselyPlugin.productActivity?.activity = null
136
- super.onDestroy()
137
- }
138
-
139
134
  private val callback: (PLYProductViewResult, PLYPlan?) -> Unit = { result, plan ->
140
135
  PurchaselyPlugin.sendPurchaseResult(
141
136
  result,
@@ -136,6 +136,7 @@ class PurchaselyPlugin : CordovaPlugin() {
136
136
  "restoreAllProducts" -> restoreAllProducts(callbackContext)
137
137
  "silentRestoreAllProducts" -> restoreAllProducts(callbackContext)
138
138
  "userSubscriptions" -> userSubscriptions(callbackContext)
139
+ "userSubscriptionsHistory" -> userSubscriptionsHistory(callbackContext)
139
140
  "isDeeplinkHandled" -> isDeeplinkHandled(
140
141
  getStringFromJson(args.getString(0)),
141
142
  callbackContext
@@ -539,6 +540,38 @@ class PurchaselyPlugin : CordovaPlugin() {
539
540
  )
540
541
  }
541
542
 
543
+ private fun userSubscriptionsHistory(callbackContext: CallbackContext) {
544
+ Purchasely.userSubscriptionsHistory(
545
+ false,
546
+ object : SubscriptionsListener {
547
+ override fun onSuccess(list: List<PLYSubscriptionData>) {
548
+ val result = JSONArray()
549
+ for (i in list.indices) {
550
+ val data = list[i]
551
+ val map = HashMap(data.toMap())
552
+ map["plan"] = transformPlanToMap(data.plan)
553
+ map["product"] = data.product.toMap()
554
+ if (data.data.storeType == StoreType.GOOGLE_PLAY_STORE) {
555
+ map["subscriptionSource"] = StoreType.GOOGLE_PLAY_STORE.ordinal
556
+ } else if (data.data.storeType == StoreType.AMAZON_APP_STORE) {
557
+ map["subscriptionSource"] = StoreType.AMAZON_APP_STORE.ordinal
558
+ } else if (data.data.storeType == StoreType.HUAWEI_APP_GALLERY) {
559
+ map["subscriptionSource"] = StoreType.HUAWEI_APP_GALLERY.ordinal
560
+ } else if (data.data.storeType == StoreType.APPLE_APP_STORE) {
561
+ map["subscriptionSource"] = StoreType.APPLE_APP_STORE.ordinal
562
+ }
563
+ result.put(JSONObject(map))
564
+ }
565
+ callbackContext.success(result)
566
+ }
567
+
568
+ override fun onFailure(throwable: Throwable) {
569
+ callbackContext.error(throwable.message)
570
+ }
571
+ }
572
+ )
573
+ }
574
+
542
575
  private fun isDeeplinkHandled(deeplink: String?, callbackContext: CallbackContext) {
543
576
  if (deeplink == null) {
544
577
  callbackContext.error("Deeplink must not be null")
@@ -46,6 +46,7 @@
46
46
  - (void)productWithIdentifier:(CDVInvokedUrlCommand*)command;
47
47
  - (void)planWithIdentifier:(CDVInvokedUrlCommand*)command;
48
48
  - (void)userSubscriptions:(CDVInvokedUrlCommand*)command;
49
+ - (void)userSubscriptionsHistory:(CDVInvokedUrlCommand*)command;
49
50
  - (void)addEventsListener:(CDVInvokedUrlCommand*)command;
50
51
  - (void)removeEventsListener:(CDVInvokedUrlCommand*)command;
51
52
  - (void)isDeeplinkHandled:(CDVInvokedUrlCommand*)command;
@@ -120,7 +120,7 @@
120
120
  if (isFullscreen) {
121
121
  navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
122
122
  }
123
- [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
123
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
124
124
  }
125
125
  }
126
126
 
@@ -146,7 +146,7 @@
146
146
  if (isFullscreen) {
147
147
  navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
148
148
  }
149
- [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
149
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
150
150
  }
151
151
  }
152
152
 
@@ -173,7 +173,7 @@
173
173
  if (isFullscreen) {
174
174
  navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
175
175
  }
176
- [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
176
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
177
177
  }
178
178
  }
179
179
 
@@ -200,7 +200,7 @@
200
200
  if (isFullscreen) {
201
201
  navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
202
202
  }
203
- [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
203
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
204
204
  }
205
205
  }
206
206
 
@@ -209,7 +209,7 @@
209
209
  UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
210
210
  ctrl.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:navCtrl action:@selector(close)];
211
211
 
212
- [Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList];
212
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList from:nil];
213
213
  }
214
214
 
215
215
  - (void)purchaseWithPlanVendorId:(CDVInvokedUrlCommand*)command {
@@ -346,6 +346,20 @@
346
346
  }];
347
347
  }
348
348
 
349
+ - (void)userSubscriptionsHistory:(CDVInvokedUrlCommand*)command {
350
+ [Purchasely userSubscriptionsHistory:false
351
+ success:^(NSArray<PLYSubscription *> * _Nullable subscriptions) {
352
+ NSMutableArray *result = [NSMutableArray new];
353
+ for (PLYSubscription *subscription in subscriptions) {
354
+ [result addObject:subscription.asDictionary];
355
+ }
356
+ [self successFor:command resultArray:result];
357
+ }
358
+ failure:^(NSError * _Nonnull error) {
359
+ [self failureFor:command resultString:error.localizedDescription];
360
+ }];
361
+ }
362
+
349
363
  - (void)addEventsListener:(CDVInvokedUrlCommand*)command {
350
364
  [Purchasely setEventDelegate:self];
351
365
  self.eventCommand = command;
@@ -555,7 +569,7 @@
555
569
  if (self.presentedPresentationViewController && self.shouldReopenPaywall) {
556
570
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
557
571
  self.shouldReopenPaywall = NO;
558
- [Purchasely showController:self.presentedPresentationViewController type:PLYUIControllerTypeProductPage];
572
+ [Purchasely showController:self.presentedPresentationViewController type:PLYUIControllerTypeProductPage from:nil];
559
573
  });
560
574
  }
561
575
  });
@@ -712,7 +726,7 @@
712
726
  [Purchasely closeDisplayedPresentation];
713
727
  self.presentedPresentationViewController = presentationLoaded.controller;
714
728
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
715
- [Purchasely showController:presentationLoaded.controller type: PLYUIControllerTypeProductPage];
729
+ [Purchasely showController:presentationLoaded.controller type: PLYUIControllerTypeProductPage from:nil];
716
730
  });
717
731
  }
718
732
  });
package/www/Purchasely.js CHANGED
@@ -5,7 +5,7 @@ var defaultError = (e) => { console.log(e); }
5
5
  exports.start = function (apiKey, stores, storekit1, userId, logLevel, runningMode, success, error) {
6
6
  var cordovaSdkVersion = cordova.define.moduleMap['cordova/plugin_list'].exports['metadata']['cordova-plugin-purchasely']
7
7
  if(!cordovaSdkVersion) {
8
- cordovaSdkVersion = "4.3.1";
8
+ cordovaSdkVersion = "4.4.0";
9
9
  }
10
10
  exec(success, error, 'Purchasely', 'start', [apiKey, stores, storekit1, userId, logLevel, runningMode, cordovaSdkVersion]);
11
11
  };
@@ -130,6 +130,10 @@ exports.userSubscriptions = function (success, error) {
130
130
  exec(success, defaultError, 'Purchasely', 'userSubscriptions', []);
131
131
  };
132
132
 
133
+ exports.userSubscriptionsHistory = function (success, error) {
134
+ exec(success, defaultError, 'Purchasely', 'userSubscriptionsHistory', []);
135
+ };
136
+
133
137
  exports.setLanguage = function (language) {
134
138
  exec(() => {}, defaultError, 'Purchasely', 'setLanguage', [language]);
135
139
  };