@purchasely/cordova-plugin-purchasely 6.0.0-rc.3 → 6.0.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.
@@ -258,7 +258,7 @@ function onPurchaselySdkReady() {
258
258
  return Purchasely.InterceptResult.notHandled;
259
259
  });
260
260
 
261
- Purchasely.interceptAction(Purchasely.PresentationAction.close_all, (info, parameters) => {
261
+ Purchasely.interceptAction(Purchasely.PresentationAction.closeAll, (info, parameters) => {
262
262
  console.log('[interceptAction] close_all — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
263
263
  return Purchasely.InterceptResult.notHandled;
264
264
  });
@@ -271,12 +271,12 @@ function onPurchaselySdkReady() {
271
271
  return Purchasely.InterceptResult.success;
272
272
  });
273
273
 
274
- Purchasely.interceptAction(Purchasely.PresentationAction.open_presentation, (info, parameters) => {
274
+ Purchasely.interceptAction(Purchasely.PresentationAction.openPresentation, (info, parameters) => {
275
275
  console.log('[interceptAction] open_presentation — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
276
276
  return Purchasely.InterceptResult.notHandled;
277
277
  });
278
278
 
279
- Purchasely.interceptAction(Purchasely.PresentationAction.open_placement, (info, parameters) => {
279
+ Purchasely.interceptAction(Purchasely.PresentationAction.openPlacement, (info, parameters) => {
280
280
  console.log('[interceptAction] open_placement — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
281
281
  return Purchasely.InterceptResult.notHandled;
282
282
  });
@@ -287,7 +287,7 @@ function onPurchaselySdkReady() {
287
287
  return Purchasely.InterceptResult.notHandled;
288
288
  });
289
289
 
290
- Purchasely.interceptAction(Purchasely.PresentationAction.web_checkout, (info, parameters) => {
290
+ Purchasely.interceptAction(Purchasely.PresentationAction.webCheckout, (info, parameters) => {
291
291
  console.log('[interceptAction] web_checkout — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
292
292
  return Purchasely.InterceptResult.notHandled;
293
293
  });
@@ -295,72 +295,76 @@ function onPurchaselySdkReady() {
295
295
  Purchasely.clearBuiltInAttributes();
296
296
  }
297
297
 
298
+ // Purchasely 6.0: `back()`/`close()` live on the request, not as bare top-level calls
299
+ // (backPresentation() was removed). The example keeps a reference to the last request
300
+ // it built/displayed so the "Back presentation" button below has something to drive.
301
+ var currentPresentationRequest = null;
302
+
298
303
  function openPresentation() {
299
- Purchasely.presentPresentationForPlacement(
300
- 'ONBOARDING', //placementId
301
- null, //contentId
302
- Purchasely.TransitionType.fullScreen, //display mode (string) — or a transition object, see below
303
- (callback) => {
304
- console.log('[openPresentation] onDismissed — purchaseResult=' + callback.purchaseResult + ' — outcome: ' + safeStringify(callback));
305
- if(callback.result == Purchasely.PurchaseResult.CANCELLED) {
306
- console.log("User cancelled purchased - close reason " + callback.closeReason);
304
+ // Purchasely 6.0: the v6 builder — pick a source (.placement/.screen/.defaultSource),
305
+ // chain lifecycle callbacks, .build(), then .display(transition?). display() resolves
306
+ // at dismiss with a 5-field outcome: { presentation, purchaseResult, plan, closeReason, error }.
307
+ currentPresentationRequest = Purchasely.presentation
308
+ .placement('ONBOARDING')
309
+ .onPresented((presentation, error) => {
310
+ console.log('[openPresentation] onPresented — ' + (presentation ? presentation.screenId : '') + (error ? ' error=' + error : ''));
311
+ })
312
+ .onCloseRequested(() => {
313
+ console.log('[openPresentation] onCloseRequested');
314
+ })
315
+ .build();
316
+
317
+ currentPresentationRequest
318
+ .display(Purchasely.TransitionType.fullScreen) //display mode (string) — or a transition object, see below
319
+ .then((outcome) => {
320
+ console.log('[openPresentation] onDismissed — purchaseResult=' + outcome.purchaseResult + ' — outcome: ' + safeStringify(outcome));
321
+ if (outcome.error) {
322
+ console.log("[openPresentation] error: " + outcome.error);
323
+ } else if (outcome.purchaseResult === 'purchased' || outcome.purchaseResult === 'restored') {
324
+ console.log("User purchased " + (outcome.plan ? outcome.plan.name : ''));
307
325
  } else {
308
- console.log("User purchased " + (callback.plan ? callback.plan.name : ''));
326
+ console.log("User cancelled purchased - close reason " + outcome.closeReason);
309
327
  }
310
- },
311
- (error) => {
312
- console.log("[openPresentation] error: " + error);
313
- },
314
- // Purchasely 6.0: optional per-request lifecycle callbacks.
315
- {
316
- onPresented: (presentation, error) => {
317
- console.log('[openPresentation] onPresented — ' + (presentation ? presentation.screenId : '') + (error ? ' error=' + error : ''));
318
- },
319
- onCloseRequested: () => {
320
- console.log('[openPresentation] onCloseRequested');
321
- }
322
- }
323
- );
328
+ });
324
329
 
325
330
  // Purchasely 6.0 also supports:
326
331
  // - a rich transition object for drawer/popin sizing (see fetchPresentation below):
327
332
  // { type: Purchasely.TransitionType.drawer, dismissible: true,
328
333
  // height: { type: Purchasely.DimensionType.percentage, value: 0.8 }, backgroundColor: '#000000' }
329
- // - the default (audience-targeted) presentation:
330
- // Purchasely.presentPresentationForDefault(null, Purchasely.TransitionType.fullScreen, ok, err);
331
- // Purchasely.fetchPresentationForDefault(null, onLoaded, err);
334
+ // - the default (audience-targeted) presentation, targeted with .defaultSource() (or its
335
+ // iOS-style alias .default()):
336
+ // Purchasely.presentation.defaultSource().build().display(Purchasely.TransitionType.fullScreen);
332
337
  // - stopping campaign/deeplink dismiss outcomes:
333
338
  // Purchasely.removeDefaultPresentationDismissHandler();
334
339
  }
335
340
 
336
341
  function fetchPresentation() {
337
- Purchasely.fetchPresentationForPlacement(
338
- 'flow_demo', //placementId
339
- null, //contentId
340
- (presentation) => {
341
- console.log('[fetchPresentation] onFetched — presentation: ' + safeStringify(presentation));
342
- // Rich transition object: drawer at 80% height, dismissible. (iOS applies the
343
- // percentage height + dismissible; Android also supports pixel + popin width.)
344
- Purchasely.presentPresentation(presentation, {
345
- type: Purchasely.TransitionType.drawer,
346
- dismissible: true,
347
- height: { type: Purchasely.DimensionType.percentage, value: 0.8 }
348
- }, null,
349
- (callback) => {
350
- console.log('[fetchPresentation → presentPresentation] onDismissed — purchaseResult=' + callback.purchaseResult + ' — outcome: ' + safeStringify(callback));
351
- if(callback.result == Purchasely.PurchaseResult.CANCELLED) {
352
- console.log("User cancelled purchased - close reason " + callback.closeReason);
353
- } else {
354
- console.log("User purchased " + (callback.plan ? callback.plan.name : ''));
355
- }
356
- }, (error) => {
357
- console.log("[fetchPresentation → presentPresentation] error: " + error);
358
- });
359
- },
360
- (error) => {
361
- console.log("[fetchPresentation] error: " + error);
362
- }
363
- );
342
+ // Purchasely 6.0: preload() fetches without displaying; the resolved presentation
343
+ // exposes screenId (the authoritative identifier). Calling display() on the SAME
344
+ // request re-displays exactly what was preloaded.
345
+ const request = Purchasely.presentation.placement('flow_demo').build();
346
+ currentPresentationRequest = request;
347
+ request.preload().then((presentation) => {
348
+ console.log('[fetchPresentation] onFetched — presentation: ' + safeStringify(presentation));
349
+ // Rich transition object: drawer at 80% height, dismissible. (iOS applies the
350
+ // percentage height + dismissible; Android also supports pixel + popin width.)
351
+ request.display({
352
+ type: Purchasely.TransitionType.drawer,
353
+ dismissible: true,
354
+ height: { type: Purchasely.DimensionType.percentage, value: 0.8 }
355
+ }).then((outcome) => {
356
+ console.log('[fetchPresentation → display] onDismissed — purchaseResult=' + outcome.purchaseResult + ' — outcome: ' + safeStringify(outcome));
357
+ if (outcome.error) {
358
+ console.log("[fetchPresentation → display] error: " + outcome.error);
359
+ } else if (outcome.purchaseResult === 'purchased' || outcome.purchaseResult === 'restored') {
360
+ console.log("User purchased " + (outcome.plan ? outcome.plan.name : ''));
361
+ } else {
362
+ console.log("User cancelled purchased - close reason " + outcome.closeReason);
363
+ }
364
+ });
365
+ }, (error) => {
366
+ console.log("[fetchPresentation] error: " + safeStringify(error));
367
+ });
364
368
  }
365
369
 
366
370
  function purchaseWithPlanVendorId() {
@@ -378,7 +382,7 @@ function processToPayment() {
378
382
  }
379
383
 
380
384
  function backPresentation() {
381
- Purchasely.backPresentation();
385
+ if (currentPresentationRequest) currentPresentationRequest.back();
382
386
  }
383
387
 
384
388
  function closePresentation() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purchasely/cordova-plugin-purchasely",
3
- "version": "6.0.0-rc.3",
3
+ "version": "6.0.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="6.0.0-rc.3" 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="6.0.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" />
@@ -38,7 +38,7 @@
38
38
  <source url="https://github.com/CocoaPods/Specs.git"/>
39
39
  </config>
40
40
  <pods use-frameworks="true">
41
- <pod name="Purchasely" spec="6.0.0-rc.3"/>
41
+ <pod name="Purchasely" spec="6.0.0"/>
42
42
  </pods>
43
43
  </podspec>
44
44
  </platform>
@@ -53,7 +53,7 @@
53
53
  <preference name="GradlePluginKotlinCodeStyle" value="official" />
54
54
  </config-file>
55
55
  <framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
56
- <framework src="io.purchasely:core:6.0.0-rc.3" />
56
+ <framework src="io.purchasely:core:6.0.1" />
57
57
  <source-file src="src/android/PurchaselyPlugin.kt" target-dir="java/cordova/plugin/purchasely" />
58
58
  </platform>
59
59
  </plugin>