@purchasely/cordova-plugin-purchasely 5.7.3 → 6.0.0-rc.3
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 +12 -8
- package/__tests__/Purchasely.test.js +307 -92
- package/example/config.xml +1 -11
- package/example/e2e/README.md +44 -0
- package/example/e2e/helpers/driver.js +70 -0
- package/example/e2e/package.json +19 -0
- package/example/e2e/specs/bridge.e2e.js +51 -0
- package/example/e2e/specs/dismiss.e2e.js +37 -0
- package/example/e2e/tools/ci_run_e2e.sh +49 -0
- package/example/e2e/tools/ci_run_e2e_ios.sh +46 -0
- package/example/e2e/wdio.android.conf.js +21 -0
- package/example/e2e/wdio.ios.conf.js +19 -0
- package/example/e2e/wdio.shared.conf.js +28 -0
- package/example/package-lock.json +59 -205
- package/example/package.json +7 -6
- package/example/www/index.html +1 -7
- package/example/www/js/index.js +113 -92
- package/package.json +1 -1
- package/plugin.xml +4 -22
- package/src/android/PurchaselyPlugin.kt +529 -440
- package/src/ios/CDVPurchasely+Events.h +1 -1
- package/src/ios/CDVPurchasely+UserAttributes.h +1 -1
- package/src/ios/CDVPurchasely+UserAttributes.m +2 -0
- package/src/ios/CDVPurchasely.h +21 -16
- package/src/ios/CDVPurchasely.m +497 -261
- package/www/Purchasely.js +208 -40
- package/src/android/PLYProductActivity.kt +0 -168
- package/src/android/PLYSubscriptionsActivity.java +0 -37
- package/src/android/activity_ply_product_activity.xml +0 -6
- package/src/android/activity_ply_subscriptions_activity.xml +0 -6
- package/src/android/theme_purchasely_fullscreen.xml +0 -6
- package/src/android/theme_purchasely_fullscreen_v23.xml +0 -6
- package/src/android/theme_purchasely_fullscreen_v23_light_status_bar.xml +0 -7
package/www/Purchasely.js
CHANGED
|
@@ -2,12 +2,64 @@ var exec = require('cordova/exec');
|
|
|
2
2
|
|
|
3
3
|
var defaultError = (e) => { console.log(e); }
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// Normalize a presentation transition. Accepts, for source compatibility:
|
|
6
|
+
// - a display-mode string ('fullScreen'|'modal'|'drawer'|'popin'|'push'|'inlinePaywall')
|
|
7
|
+
// - a legacy boolean (true -> fullScreen, false -> modal)
|
|
8
|
+
// - a full transition object { type, dismissible?, width?, height?, backgroundColor? }
|
|
9
|
+
// where width/height are { type: 'pixel'|'percentage', value: Number } (width is
|
|
10
|
+
// popin-only, height drives drawer+popin) and backgroundColor is a hex string.
|
|
11
|
+
// Always returns a transition object for the native bridge.
|
|
12
|
+
function normalizeTransition(mode) {
|
|
13
|
+
if (mode === true) return { type: 'fullScreen' };
|
|
14
|
+
if (mode === false) return { type: 'modal' };
|
|
15
|
+
if (typeof mode === 'string') return { type: mode };
|
|
16
|
+
if (mode && typeof mode === 'object' && mode.type) return mode;
|
|
17
|
+
return { type: 'fullScreen' };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Wire a present* command's callback stream. Purchasely 6.0 emits presentation
|
|
21
|
+
// lifecycle events during display: the native side sends keep-alive envelopes
|
|
22
|
+
// { event: 'presented', presentation } and { event: 'closeRequested' }, then the
|
|
23
|
+
// dismiss OUTCOME (which has no `event` key) as the final, non-kept callback.
|
|
24
|
+
// `callbacks` may carry onPresented(presentation, error) and onCloseRequested().
|
|
25
|
+
function presentationDispatcher(success, callbacks) {
|
|
26
|
+
callbacks = callbacks || {};
|
|
27
|
+
return function (payload) {
|
|
28
|
+
if (payload && payload.event === 'presented') {
|
|
29
|
+
if (callbacks.onPresented) callbacks.onPresented(payload.presentation || null, payload.error || null);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (payload && payload.event === 'closeRequested') {
|
|
33
|
+
if (callbacks.onCloseRequested) callbacks.onCloseRequested();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (success) success(payload);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Purchasely 6.0: `start` now takes a single options object instead of a
|
|
41
|
+
// positional argument list. Existing positional calls are no longer supported
|
|
42
|
+
// (see MIGRATION-v6.md).
|
|
43
|
+
//
|
|
44
|
+
// options:
|
|
45
|
+
// apiKey (string, required)
|
|
46
|
+
// appUserId (string, optional)
|
|
47
|
+
// logLevel (int, optional — see Purchasely.LogLevel)
|
|
48
|
+
// runningMode (string, optional — see Purchasely.RunningMode; defaults to observer)
|
|
49
|
+
// stores (string[], optional — see Purchasely.Store)
|
|
50
|
+
// storeKit1 (bool, optional — iOS; true forces StoreKit 1)
|
|
51
|
+
// storekitVersion (string, optional — iOS; see Purchasely.StorekitVersion)
|
|
52
|
+
// allowDeeplink (bool, optional)
|
|
53
|
+
// allowCampaigns (bool, optional)
|
|
54
|
+
// deeplink (string, optional — cold-start deeplink URL)
|
|
55
|
+
exports.start = function (options, success, error) {
|
|
56
|
+
var opts = options || {};
|
|
6
57
|
var cordovaSdkVersion = cordova.define.moduleMap['cordova/plugin_list'].exports['metadata']['cordova-plugin-purchasely']
|
|
7
58
|
if(!cordovaSdkVersion) {
|
|
8
|
-
cordovaSdkVersion = "
|
|
59
|
+
cordovaSdkVersion = "6.0.0-rc.3";
|
|
9
60
|
}
|
|
10
|
-
|
|
61
|
+
opts.sdkVersion = cordovaSdkVersion;
|
|
62
|
+
exec(success, error, 'Purchasely', 'start', [opts]);
|
|
11
63
|
};
|
|
12
64
|
|
|
13
65
|
exports.addEventsListener = function (success, error) {
|
|
@@ -46,32 +98,47 @@ exports.setAttribute = function (attribute, value) {
|
|
|
46
98
|
exec(() => {}, defaultError, 'Purchasely', 'setAttribute', [attribute, value]);
|
|
47
99
|
};
|
|
48
100
|
|
|
49
|
-
|
|
50
|
-
|
|
101
|
+
// Purchasely 6.0: allow (or defer) the SDK from opening deeplinks.
|
|
102
|
+
exports.allowDeeplink = function (allow) {
|
|
103
|
+
exec(() => {}, defaultError, 'Purchasely', 'allowDeeplink', [allow]);
|
|
51
104
|
};
|
|
52
105
|
|
|
53
|
-
|
|
54
|
-
|
|
106
|
+
// Purchasely 6.0: allow (or defer) the SDK from displaying campaign deeplinks.
|
|
107
|
+
exports.allowCampaigns = function (allow) {
|
|
108
|
+
exec(() => {}, defaultError, 'Purchasely', 'allowCampaigns', [allow]);
|
|
55
109
|
};
|
|
56
110
|
|
|
57
|
-
exports.
|
|
58
|
-
exec(
|
|
111
|
+
exports.setDefaultPresentationDismissHandler = function (success, error) {
|
|
112
|
+
exec(success, error, 'Purchasely', 'setDefaultPresentationDismissHandler', []);
|
|
59
113
|
};
|
|
60
114
|
|
|
61
|
-
|
|
62
|
-
|
|
115
|
+
// Purchasely 6.0: stop receiving default (campaign/deeplink) presentation dismiss outcomes.
|
|
116
|
+
exports.removeDefaultPresentationDismissHandler = function () {
|
|
117
|
+
exec(() => {}, defaultError, 'Purchasely', 'removeDefaultPresentationDismissHandler', []);
|
|
63
118
|
};
|
|
64
119
|
|
|
65
|
-
|
|
66
|
-
|
|
120
|
+
// Purchasely 6.0: synchronize now reports completion. success receives true on
|
|
121
|
+
// success; error is invoked on failure (previously fire-and-forget).
|
|
122
|
+
exports.synchronize = function (success, error) {
|
|
123
|
+
exec(success || (() => {}), error || defaultError, 'Purchasely', 'synchronize', []);
|
|
67
124
|
};
|
|
68
125
|
|
|
69
|
-
|
|
70
|
-
|
|
126
|
+
// present* methods: `displayMode` accepts a mode string, a legacy boolean, or a
|
|
127
|
+
// full transition object (see normalizeTransition). `callbacks` is optional and
|
|
128
|
+
// may carry { onPresented(presentation, error), onCloseRequested() }; `success`
|
|
129
|
+
// still receives the final dismiss outcome.
|
|
130
|
+
exports.presentPresentationWithIdentifier = function (presentationId, contentId, displayMode, success, error, callbacks) {
|
|
131
|
+
exec(presentationDispatcher(success, callbacks), error, 'Purchasely', 'presentPresentationWithIdentifier', [presentationId, contentId, normalizeTransition(displayMode)]);
|
|
71
132
|
};
|
|
72
133
|
|
|
73
|
-
exports.
|
|
74
|
-
exec(success, error, 'Purchasely', '
|
|
134
|
+
exports.presentPresentationForPlacement = function (placementId, contentId, displayMode, success, error, callbacks) {
|
|
135
|
+
exec(presentationDispatcher(success, callbacks), error, 'Purchasely', 'presentPresentationForPlacement', [placementId, contentId, normalizeTransition(displayMode)]);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Purchasely 6.0: present the default (audience-targeted) presentation, with no
|
|
139
|
+
// placement or presentation id (mirrors the native default presentation source).
|
|
140
|
+
exports.presentPresentationForDefault = function (contentId, displayMode, success, error, callbacks) {
|
|
141
|
+
exec(presentationDispatcher(success, callbacks), error, 'Purchasely', 'presentPresentationForDefault', [contentId, normalizeTransition(displayMode)]);
|
|
75
142
|
};
|
|
76
143
|
|
|
77
144
|
exports.fetchPresentation = function (presentationId, contentId, success, error) {
|
|
@@ -82,12 +149,13 @@ exports.fetchPresentationForPlacement = function (placementId, contentId, succes
|
|
|
82
149
|
exec(success, error, 'Purchasely', 'fetchPresentation', [placementId, null, contentId]);
|
|
83
150
|
};
|
|
84
151
|
|
|
85
|
-
|
|
86
|
-
|
|
152
|
+
// Purchasely 6.0: fetch the default (audience-targeted) presentation.
|
|
153
|
+
exports.fetchPresentationForDefault = function (contentId, success, error) {
|
|
154
|
+
exec(success, error, 'Purchasely', 'fetchPresentation', [null, null, contentId]);
|
|
87
155
|
};
|
|
88
156
|
|
|
89
|
-
exports.
|
|
90
|
-
exec(()
|
|
157
|
+
exports.presentPresentation = function (presentation, displayMode, backgroundColor, success, error, callbacks) {
|
|
158
|
+
exec(presentationDispatcher(success, callbacks), error, 'Purchasely', 'presentPresentation', [presentation, normalizeTransition(displayMode), backgroundColor]);
|
|
91
159
|
};
|
|
92
160
|
|
|
93
161
|
exports.purchaseWithPlanVendorId = function (planId, offerId, contentId, success, error) {
|
|
@@ -106,8 +174,9 @@ exports.purchasedSubscription = function (success, error) {
|
|
|
106
174
|
exec(success, error, 'Purchasely', 'purchasedSubscription', []);
|
|
107
175
|
};
|
|
108
176
|
|
|
109
|
-
|
|
110
|
-
|
|
177
|
+
// Purchasely 6.0: returns whether the deeplink was handled by Purchasely.
|
|
178
|
+
exports.handleDeeplink = function (deepLink, success, error) {
|
|
179
|
+
exec(success, error, 'Purchasely', 'handleDeeplink', [deepLink]);
|
|
111
180
|
};
|
|
112
181
|
|
|
113
182
|
exports.allProducts = function (success, error) {
|
|
@@ -122,12 +191,53 @@ exports.productWithIdentifier = function (productId, success) {
|
|
|
122
191
|
exec(success, defaultError, 'Purchasely', 'productWithIdentifier', [productId]);
|
|
123
192
|
};
|
|
124
193
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
194
|
+
// Purchasely 6.0: per-action interceptor. Registers a handler for a single
|
|
195
|
+
// action kind (see Purchasely.PresentationAction). The handler receives
|
|
196
|
+
// (info, parameters) and returns — or resolves to — a Purchasely.InterceptResult
|
|
197
|
+
// ('success' | 'failed' | 'notHandled'). Registering a kind again replaces its
|
|
198
|
+
// handler. This maps 1:1 onto the native v6 SDK, which intercepts per action.
|
|
199
|
+
var _actionInterceptors = {}; // kind -> true (registered)
|
|
128
200
|
|
|
129
|
-
|
|
130
|
-
|
|
201
|
+
function normalizeInterceptResult(result) {
|
|
202
|
+
if (result === 'success' || result === 'failed' || result === 'notHandled') return result;
|
|
203
|
+
return 'notHandled';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
exports.interceptAction = function (kind, handler) {
|
|
207
|
+
exports.removeActionInterceptor(kind);
|
|
208
|
+
_actionInterceptors[kind] = true;
|
|
209
|
+
exec(function (event) {
|
|
210
|
+
// Native registers one interceptor per kind, so events only arrive for
|
|
211
|
+
// this kind; guard anyway. `callbackId` ties the async reply back to the
|
|
212
|
+
// exact intercepted invocation, so concurrent intercepts never clobber.
|
|
213
|
+
if (!event || event.action !== kind) return;
|
|
214
|
+
Promise.resolve()
|
|
215
|
+
.then(function () { return handler(event.info || null, event.parameters || null); })
|
|
216
|
+
.then(function (result) {
|
|
217
|
+
exec(function () {}, defaultError, 'Purchasely', 'completeActionInterceptor',
|
|
218
|
+
[event.callbackId, normalizeInterceptResult(result)]);
|
|
219
|
+
})
|
|
220
|
+
.catch(function () {
|
|
221
|
+
exec(function () {}, defaultError, 'Purchasely', 'completeActionInterceptor',
|
|
222
|
+
[event.callbackId, 'failed']);
|
|
223
|
+
});
|
|
224
|
+
}, defaultError, 'Purchasely', 'registerActionInterceptor', [kind]);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// Purchasely 6.0: stop intercepting a single action kind.
|
|
228
|
+
exports.removeActionInterceptor = function (kind, success, error) {
|
|
229
|
+
delete _actionInterceptors[kind];
|
|
230
|
+
exec(function () {}, defaultError, 'Purchasely', 'unregisterActionInterceptor', [kind]);
|
|
231
|
+
if (success) setTimeout(success, 0);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// Purchasely 6.0: stop intercepting every registered action kind.
|
|
235
|
+
exports.removeAllActionInterceptors = function (success, error) {
|
|
236
|
+
Object.keys(_actionInterceptors).forEach(function (kind) {
|
|
237
|
+
delete _actionInterceptors[kind];
|
|
238
|
+
exec(function () {}, defaultError, 'Purchasely', 'unregisterActionInterceptor', [kind]);
|
|
239
|
+
});
|
|
240
|
+
if (success) setTimeout(success, 0);
|
|
131
241
|
};
|
|
132
242
|
|
|
133
243
|
exports.userDidConsumeSubscriptionContent = function () {
|
|
@@ -146,18 +256,16 @@ exports.setLanguage = function (language) {
|
|
|
146
256
|
exec(() => {}, defaultError, 'Purchasely', 'setLanguage', [language]);
|
|
147
257
|
};
|
|
148
258
|
|
|
149
|
-
|
|
150
|
-
exec(() => {}, defaultError, 'Purchasely', 'showPresentation', []);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
exports.hidePresentation = function () {
|
|
154
|
-
exec(() => {}, defaultError, 'Purchasely', 'hidePresentation', []);
|
|
155
|
-
};
|
|
156
|
-
|
|
259
|
+
// Purchasely 6.0: close the displayed presentation.
|
|
157
260
|
exports.closePresentation = function () {
|
|
158
261
|
exec(() => {}, defaultError, 'Purchasely', 'closePresentation', []);
|
|
159
262
|
};
|
|
160
263
|
|
|
264
|
+
// Purchasely 6.0: navigate back within the displayed presentation.
|
|
265
|
+
exports.backPresentation = function () {
|
|
266
|
+
exec(() => {}, defaultError, 'Purchasely', 'backPresentation', []);
|
|
267
|
+
};
|
|
268
|
+
|
|
161
269
|
exports.setUserAttributeWithString = function (key, value, processLegalBasis) {
|
|
162
270
|
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithString', [key, value, processLegalBasis]);
|
|
163
271
|
};
|
|
@@ -297,12 +405,15 @@ exports.PlanType = {
|
|
|
297
405
|
unknown: 4
|
|
298
406
|
}
|
|
299
407
|
|
|
408
|
+
// Purchasely 6.0: running mode is passed by name (the native iOS and Android
|
|
409
|
+
// enums use different raw values). Native 6.0 exposes only observer and full.
|
|
300
410
|
exports.RunningMode = {
|
|
301
|
-
|
|
302
|
-
full:
|
|
411
|
+
observer: 'observer',
|
|
412
|
+
full: 'full'
|
|
303
413
|
}
|
|
304
414
|
|
|
305
|
-
|
|
415
|
+
// Purchasely 6.0: the paywall action kinds handled by interceptAction.
|
|
416
|
+
exports.PresentationAction = {
|
|
306
417
|
close: 'close',
|
|
307
418
|
close_all: 'close_all',
|
|
308
419
|
login: 'login',
|
|
@@ -315,6 +426,63 @@ exports.PaywallAction = {
|
|
|
315
426
|
web_checkout: 'web_checkout'
|
|
316
427
|
}
|
|
317
428
|
|
|
429
|
+
// Purchasely 6.0: result returned by an interceptAction handler after handling
|
|
430
|
+
// an intercepted paywall action.
|
|
431
|
+
exports.InterceptResult = {
|
|
432
|
+
success: 'success',
|
|
433
|
+
failed: 'failed',
|
|
434
|
+
notHandled: 'notHandled'
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Purchasely 6.0: the type of a fetched presentation.
|
|
438
|
+
exports.PresentationType = {
|
|
439
|
+
normal: 0,
|
|
440
|
+
fallback: 1,
|
|
441
|
+
deactivated: 2,
|
|
442
|
+
client: 3
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Purchasely 6.0: why a presentation closed (delivered in the dismiss outcome).
|
|
446
|
+
// Matches the native PLYCloseReason wire contract (identical to the Flutter
|
|
447
|
+
// PLYCloseReason enum): `button`, `back_system`, `programmatic`. Android emits
|
|
448
|
+
// these directly; on iOS a swipe/interactive dismiss maps to `back_system`, and
|
|
449
|
+
// a close with no dismiss reason (e.g. after a purchase) omits the key.
|
|
450
|
+
exports.CloseReason = {
|
|
451
|
+
button: 'button',
|
|
452
|
+
backSystem: 'back_system',
|
|
453
|
+
programmatic: 'programmatic'
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Purchasely 6.0: presentation display mode, passed in place of the former
|
|
457
|
+
// `isFullscreen` boolean to the present* methods.
|
|
458
|
+
exports.TransitionType = {
|
|
459
|
+
fullScreen: 'fullScreen',
|
|
460
|
+
modal: 'modal',
|
|
461
|
+
drawer: 'drawer',
|
|
462
|
+
popin: 'popin',
|
|
463
|
+
push: 'push',
|
|
464
|
+
inlinePaywall: 'inlinePaywall'
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Purchasely 6.0: sizing unit for drawer/popin display modes.
|
|
468
|
+
exports.DimensionType = {
|
|
469
|
+
pixel: 'pixel',
|
|
470
|
+
percentage: 'percentage'
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Purchasely 6.0: stores that can be enabled at start.
|
|
474
|
+
exports.Store = {
|
|
475
|
+
google: 'Google',
|
|
476
|
+
huawei: 'Huawei',
|
|
477
|
+
amazon: 'Amazon'
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Purchasely 6.0: StoreKit version selection (iOS).
|
|
481
|
+
exports.StorekitVersion = {
|
|
482
|
+
storeKit1: 'storeKit1',
|
|
483
|
+
storeKit2: 'storeKit2'
|
|
484
|
+
}
|
|
485
|
+
|
|
318
486
|
exports.ThemeMode = {
|
|
319
487
|
light: 0,
|
|
320
488
|
dark: 1,
|
|
@@ -324,4 +492,4 @@ exports.ThemeMode = {
|
|
|
324
492
|
exports.UserAttributeAction = {
|
|
325
493
|
ADD: 'add',
|
|
326
494
|
REMOVE: 'remove'
|
|
327
|
-
}
|
|
495
|
+
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
package cordova.plugin.purchasely
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Intent
|
|
5
|
-
import android.graphics.Color
|
|
6
|
-
import android.os.Bundle
|
|
7
|
-
import android.view.View
|
|
8
|
-
import android.widget.FrameLayout
|
|
9
|
-
import androidx.appcompat.app.AppCompatActivity
|
|
10
|
-
import androidx.core.view.WindowCompat
|
|
11
|
-
import cordova.plugin.purchasely.PurchaselyPlugin.ProductActivity
|
|
12
|
-
import io.purchasely.ext.PLYPresentation
|
|
13
|
-
import io.purchasely.ext.PLYPresentationProperties
|
|
14
|
-
import io.purchasely.ext.PLYProductViewResult
|
|
15
|
-
import io.purchasely.ext.Purchasely
|
|
16
|
-
import io.purchasely.models.PLYPlan
|
|
17
|
-
import io.purchasely.views.parseColor
|
|
18
|
-
import java.lang.ref.WeakReference
|
|
19
|
-
import android.view.WindowManager
|
|
20
|
-
|
|
21
|
-
class PLYProductActivity : AppCompatActivity() {
|
|
22
|
-
|
|
23
|
-
private var presentationId: String? = null
|
|
24
|
-
private var placementId: String? = null
|
|
25
|
-
private var productId: String? = null
|
|
26
|
-
private var planId: String? = null
|
|
27
|
-
private var contentId: String? = null
|
|
28
|
-
|
|
29
|
-
private var presentation: PLYPresentation? = null
|
|
30
|
-
|
|
31
|
-
private var isFullScreen: Boolean = false
|
|
32
|
-
private var backgroundColor: String? = null
|
|
33
|
-
|
|
34
|
-
private var paywallView: View? = null
|
|
35
|
-
|
|
36
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
37
|
-
super.onCreate(savedInstanceState)
|
|
38
|
-
|
|
39
|
-
isFullScreen = intent.extras?.getBoolean("isFullScreen") ?: false
|
|
40
|
-
backgroundColor = intent.extras?.getString("background_color")
|
|
41
|
-
|
|
42
|
-
if(isFullScreen) {
|
|
43
|
-
WindowCompat.setDecorFitsSystemWindows(window, false)
|
|
44
|
-
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
val package_name = application.packageName
|
|
48
|
-
|
|
49
|
-
setContentView(
|
|
50
|
-
application.resources
|
|
51
|
-
.getIdentifier(
|
|
52
|
-
"activity_ply_product_activity",
|
|
53
|
-
"layout",
|
|
54
|
-
package_name
|
|
55
|
-
)
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
val container = findViewById<View>(
|
|
59
|
-
resources.getIdentifier(
|
|
60
|
-
"container",
|
|
61
|
-
"id",
|
|
62
|
-
package_name
|
|
63
|
-
)
|
|
64
|
-
) as FrameLayout
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
val loadingBackgroundColor = backgroundColor.parseColor(Color.WHITE)
|
|
68
|
-
container.setBackgroundColor(loadingBackgroundColor)
|
|
69
|
-
} catch (e: Exception) {
|
|
70
|
-
//do nothing
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
presentationId = intent.extras?.getString("presentationId")
|
|
74
|
-
placementId = intent.extras?.getString("placementId")
|
|
75
|
-
productId = intent.extras?.getString("productId")
|
|
76
|
-
planId = intent.extras?.getString("planId")
|
|
77
|
-
contentId = intent.extras?.getString("contentId")
|
|
78
|
-
|
|
79
|
-
presentation = intent.extras?.getParcelable("presentation")
|
|
80
|
-
|
|
81
|
-
paywallView = if(presentation != null) {
|
|
82
|
-
presentation?.buildView(this, properties = PLYPresentationProperties(onClose = {
|
|
83
|
-
container.removeAllViews()
|
|
84
|
-
supportFinishAfterTransition()
|
|
85
|
-
}), callback)
|
|
86
|
-
} else {
|
|
87
|
-
Purchasely.presentationView(
|
|
88
|
-
context = this@PLYProductActivity,
|
|
89
|
-
properties = PLYPresentationProperties(
|
|
90
|
-
placementId = placementId,
|
|
91
|
-
contentId = contentId,
|
|
92
|
-
presentationId = presentationId,
|
|
93
|
-
planId = planId,
|
|
94
|
-
productId = productId,
|
|
95
|
-
onLoaded = { isLoaded ->
|
|
96
|
-
if(!isLoaded) return@PLYPresentationProperties
|
|
97
|
-
|
|
98
|
-
val backgroundPaywall = paywallView?.findViewById<FrameLayout>(io.purchasely.R.id.content)?.background
|
|
99
|
-
if(backgroundPaywall != null) {
|
|
100
|
-
container.background = backgroundPaywall
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
onClose = {
|
|
104
|
-
container.removeAllViews()
|
|
105
|
-
supportFinishAfterTransition()
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
callback = callback
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if(paywallView == null) {
|
|
113
|
-
finish()
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
container.addView(paywallView)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
override fun onStart() {
|
|
121
|
-
super.onStart()
|
|
122
|
-
|
|
123
|
-
val productActivity = ProductActivity()
|
|
124
|
-
productActivity.presentation = presentation
|
|
125
|
-
productActivity.presentationId = presentationId
|
|
126
|
-
productActivity.placementId = placementId
|
|
127
|
-
productActivity.productId = productId
|
|
128
|
-
productActivity.planId = planId
|
|
129
|
-
productActivity.contentId = contentId
|
|
130
|
-
productActivity.isFullScreen = isFullScreen
|
|
131
|
-
productActivity.loadingBackgroundColor = backgroundColor
|
|
132
|
-
productActivity.activity = WeakReference(this)
|
|
133
|
-
PurchaselyPlugin.productActivity = productActivity
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
private val callback: (PLYProductViewResult, PLYPlan?) -> Unit = { result, plan ->
|
|
137
|
-
PurchaselyPlugin.sendPurchaseResult(
|
|
138
|
-
result,
|
|
139
|
-
plan
|
|
140
|
-
)
|
|
141
|
-
//supportFinishAfterTransition()
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
companion object {
|
|
145
|
-
@JvmStatic
|
|
146
|
-
fun newIntent(activity: Activity?,
|
|
147
|
-
properties: PLYPresentationProperties = PLYPresentationProperties(),
|
|
148
|
-
isFullScreen: Boolean = false,
|
|
149
|
-
backgroundColor: String? = null) = Intent(activity, PLYProductActivity::class.java).apply {
|
|
150
|
-
//remove old activity if still referenced to avoid issues
|
|
151
|
-
val oldActivity = PurchaselyPlugin.productActivity?.activity?.get()
|
|
152
|
-
oldActivity?.finish()
|
|
153
|
-
PurchaselyPlugin.productActivity?.activity = null
|
|
154
|
-
PurchaselyPlugin.productActivity = null
|
|
155
|
-
//flags = Intent.FLAG_ACTIVITY_NEW_TASK xor Intent.FLAG_ACTIVITY_MULTIPLE_TASK
|
|
156
|
-
|
|
157
|
-
putExtra("background_color", backgroundColor)
|
|
158
|
-
putExtra("isFullScreen", isFullScreen)
|
|
159
|
-
|
|
160
|
-
putExtra("presentationId", properties.presentationId)
|
|
161
|
-
putExtra("contentId", properties.contentId)
|
|
162
|
-
putExtra("placementId", properties.placementId)
|
|
163
|
-
putExtra("productId", properties.productId)
|
|
164
|
-
putExtra("planId", properties.planId)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
package cordova.plugin.purchasely;
|
|
2
|
-
|
|
3
|
-
import android.os.Bundle;
|
|
4
|
-
|
|
5
|
-
import androidx.annotation.Nullable;
|
|
6
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
7
|
-
|
|
8
|
-
import io.purchasely.ext.Purchasely;
|
|
9
|
-
|
|
10
|
-
public class PLYSubscriptionsActivity extends AppCompatActivity {
|
|
11
|
-
|
|
12
|
-
@Override
|
|
13
|
-
protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
|
14
|
-
super.onCreate(savedInstanceState);
|
|
15
|
-
String package_name = getApplication().getPackageName();
|
|
16
|
-
setContentView(getApplication().getResources()
|
|
17
|
-
.getIdentifier("activity_ply_subscriptions_activity",
|
|
18
|
-
"layout",
|
|
19
|
-
package_name)
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
getSupportFragmentManager()
|
|
23
|
-
.beginTransaction()
|
|
24
|
-
.addToBackStack(null)
|
|
25
|
-
.replace(getApplication().getResources()
|
|
26
|
-
.getIdentifier("fragmentContainer",
|
|
27
|
-
"id",
|
|
28
|
-
package_name), Purchasely.subscriptionsFragment(), "SubscriptionsFragment")
|
|
29
|
-
.commitAllowingStateLoss();
|
|
30
|
-
|
|
31
|
-
getSupportFragmentManager().addOnBackStackChangedListener(() -> {
|
|
32
|
-
if(getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
|
33
|
-
supportFinishAfterTransition();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<resources>
|
|
2
|
-
<style name="Theme.Purchasely.Fullscreen" parent="Theme.AppCompat.Light.NoActionBar">
|
|
3
|
-
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
4
|
-
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
5
|
-
</style>
|
|
6
|
-
</resources>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<resources>
|
|
2
|
-
<style name="Theme.Purchasely.Fullscreen" parent="Theme.AppCompat.Light.NoActionBar">
|
|
3
|
-
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
4
|
-
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
5
|
-
</style>
|
|
6
|
-
</resources>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<resources>
|
|
2
|
-
<style name="Theme.Purchasely.Fullscreen.Light" parent="Theme.AppCompat.Light.NoActionBar">
|
|
3
|
-
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
4
|
-
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
5
|
-
<item name="android:windowLightStatusBar">true</item>
|
|
6
|
-
</style>
|
|
7
|
-
</resources>
|