@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.
- package/README.md +22 -14
- package/__tests__/Purchasely.test.js +820 -155
- package/example/IOS_8_1_1_TEST_MATRIX.md +25 -0
- package/example/e2e/README.md +2 -2
- package/example/e2e/helpers/driver.js +135 -18
- package/example/e2e/specs/bridge.e2e.js +116 -13
- package/example/e2e/specs/dismiss.e2e.js +32 -12
- package/example/e2e/tools/ci_run_e2e.sh +15 -1
- package/example/e2e/tools/ci_run_e2e_ios.sh +12 -2
- package/example/e2e/wdio.android.conf.js +3 -0
- package/example/e2e/wdio.ios.conf.js +26 -1
- package/example/ios.sh +6 -5
- package/example/package-lock.json +3 -3
- package/example/package.json +2 -2
- package/example/www/js/index.js +62 -58
- package/package.json +1 -1
- package/plugin.xml +3 -3
- package/src/android/PurchaselyPlugin.kt +247 -67
- package/src/ios/CDVPurchasely+Events.m +7 -1
- package/src/ios/CDVPurchasely.h +11 -0
- package/src/ios/CDVPurchasely.m +158 -6
- package/src/ios/Hybrid/PLYPlan+Hybrid.m +19 -0
- package/src/ios/Hybrid/PLYSubscription+Hybrid.m +13 -0
- package/www/Purchasely.js +390 -46
package/example/www/js/index.js
CHANGED
|
@@ -258,7 +258,7 @@ function onPurchaselySdkReady() {
|
|
|
258
258
|
return Purchasely.InterceptResult.notHandled;
|
|
259
259
|
});
|
|
260
260
|
|
|
261
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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 " +
|
|
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
|
-
//
|
|
331
|
-
// Purchasely.
|
|
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.
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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>
|