@purchasely/cordova-plugin-purchasely 2.0.0 → 2.0.1
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 +16 -2
- package/VERSIONS.md +1 -0
- package/example/config.xml +10 -0
- package/example/www/js/index.js +3 -1
- package/package.json +1 -1
- package/plugin.xml +4 -1
- package/src/android/PLYProductActivity.java +7 -0
- package/src/android/PurchaselyPlugin.java +10 -1
- package/src/android/theme_purchasely_fullscreen.xml +6 -0
- package/src/android/theme_purchasely_fullscreen_v23.xml +6 -0
- package/src/android/theme_purchasely_fullscreen_v23_light_status_bar.xml +7 -0
- package/src/ios/CDVPurchasely.m +22 -7
- package/src/ios/Hybrid/PLYPlan+Hybrid.m +1 -1
- package/www/Purchasely.js +6 -18
package/README.md
CHANGED
|
@@ -11,10 +11,24 @@ cordova plugin add @purchasely/cordova-plugin-purchasely
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
Purchasely.startWithAPIKey(
|
|
14
|
+
Purchasely.startWithAPIKey(
|
|
15
|
+
'API_KEY',
|
|
16
|
+
['Google'], // list of stores for Android, accepted values: Google, Huawei and Amazon
|
|
17
|
+
null, // your user id
|
|
18
|
+
Purchasely.LogLevel.DEBUG, // log level, should be warning or error in production
|
|
19
|
+
Purchasely.RunningMode.full, // running mode
|
|
20
|
+
(isConfigured) => {
|
|
21
|
+
if(isConfigured) // you can use the SDK like display a paywall or make a purchase
|
|
22
|
+
},
|
|
23
|
+
(error) => {
|
|
24
|
+
console.log(error);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
15
27
|
|
|
16
28
|
Purchasely.presentPresentationWithIdentifier(
|
|
17
|
-
'my_presentation_id',
|
|
29
|
+
'my_presentation_id', // may be null
|
|
30
|
+
'my_content_id', // may be null
|
|
31
|
+
false, //display in fullscreen mode
|
|
18
32
|
(callback) => {
|
|
19
33
|
console.log(callback);
|
|
20
34
|
if(callback.result == Purchasely.PurchaseResult.CANCELLED) {
|
package/VERSIONS.md
CHANGED
package/example/config.xml
CHANGED
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
<platform name="android">
|
|
19
19
|
<allow-intent href="market:*" />
|
|
20
20
|
<preference name="AndroidXEnabled" value="true" />
|
|
21
|
+
<!--<edit-config
|
|
22
|
+
file="AndroidManifest.xml"
|
|
23
|
+
target="/manifest/application/activity[@android:name='cordova.plugin.purchasely.PLYProductActivity']"
|
|
24
|
+
mode="overwrite">
|
|
25
|
+
<activity
|
|
26
|
+
android:label="PLYProductActivity"
|
|
27
|
+
android:name="cordova.plugin.purchasely.PLYProductActivity"
|
|
28
|
+
android:theme="@style/Theme.Purchasely.Fullscreen">
|
|
29
|
+
</activity>
|
|
30
|
+
</edit-config>-->
|
|
21
31
|
</platform>
|
|
22
32
|
<platform name="ios">
|
|
23
33
|
<allow-intent href="itms:*" />
|
package/example/www/js/index.js
CHANGED
|
@@ -30,7 +30,7 @@ function onDeviceReady() {
|
|
|
30
30
|
console.log("Hi");
|
|
31
31
|
|
|
32
32
|
Purchasely.setLanguage('en')
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
Purchasely.startWithAPIKey(
|
|
35
35
|
'afa96c76-1d8e-4e3c-a48f-204a3cd93a15',
|
|
36
36
|
['Google'],
|
|
@@ -160,6 +160,8 @@ function onPuchaselySdkReady() {
|
|
|
160
160
|
function openPresentation() {
|
|
161
161
|
Purchasely.presentPresentationWithIdentifier(
|
|
162
162
|
null,
|
|
163
|
+
null,
|
|
164
|
+
true,
|
|
163
165
|
(callback) => {
|
|
164
166
|
console.log(callback);
|
|
165
167
|
if(callback.result == Purchasely.PurchaseResult.CANCELLED) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purchasely/cordova-plugin-purchasely",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
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="2.0.
|
|
2
|
+
<plugin id="@purchasely/cordova-plugin-purchasely" version="2.0.1" 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" />
|
|
@@ -56,5 +56,8 @@
|
|
|
56
56
|
<source-file src="src/android/PLYProductActivity.java" target-dir="src/cordova/plugin/purchasely" />
|
|
57
57
|
<source-file src="src/android/PLYSubscriptionsActivity.java" target-dir="src/cordova/plugin/purchasely" />
|
|
58
58
|
<source-file src="src/android/activity_ply_product_activity.xml" target-dir="res/layout"/>
|
|
59
|
+
<source-file src="src/android/theme_purchasely_fullscreen.xml" target-dir="res/values"/>
|
|
60
|
+
<source-file src="src/android/theme_purchasely_fullscreen_v23_light_status_bar.xml" target-dir="res/values-v23"/>
|
|
61
|
+
<source-file src="src/android/theme_purchasely_fullscreen_v23.xml" target-dir="res/values-v23"/>
|
|
59
62
|
</platform>
|
|
60
63
|
</plugin>
|
|
@@ -6,6 +6,7 @@ import android.os.Bundle;
|
|
|
6
6
|
|
|
7
7
|
import androidx.annotation.Nullable;
|
|
8
8
|
import androidx.appcompat.app.AppCompatActivity;
|
|
9
|
+
import androidx.core.view.WindowCompat;
|
|
9
10
|
import androidx.fragment.app.Fragment;
|
|
10
11
|
|
|
11
12
|
import java.lang.ref.WeakReference;
|
|
@@ -18,6 +19,12 @@ public class PLYProductActivity extends AppCompatActivity {
|
|
|
18
19
|
@Override
|
|
19
20
|
protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
|
20
21
|
super.onCreate(savedInstanceState);
|
|
22
|
+
|
|
23
|
+
boolean isFullScreen = getIntent().getExtras().getBoolean("isFullScreen");
|
|
24
|
+
if(isFullScreen) {
|
|
25
|
+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
String package_name = getApplication().getPackageName();
|
|
22
29
|
setContentView(getApplication().getResources()
|
|
23
30
|
.getIdentifier("activity_ply_product_activity",
|
|
@@ -123,6 +123,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
123
123
|
presentPresentationWithIdentifier(
|
|
124
124
|
args.getString(0),
|
|
125
125
|
args.getString(1),
|
|
126
|
+
args.getBoolean(2),
|
|
126
127
|
callbackContext
|
|
127
128
|
);
|
|
128
129
|
break;
|
|
@@ -131,6 +132,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
131
132
|
args.getString(0),
|
|
132
133
|
args.getString(1),
|
|
133
134
|
args.getString(2),
|
|
135
|
+
args.getBoolean(3),
|
|
134
136
|
callbackContext
|
|
135
137
|
);
|
|
136
138
|
break;
|
|
@@ -139,6 +141,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
139
141
|
args.getString(0),
|
|
140
142
|
args.getString(1),
|
|
141
143
|
args.getString(2),
|
|
144
|
+
args.getBoolean(3),
|
|
142
145
|
callbackContext
|
|
143
146
|
);
|
|
144
147
|
break;
|
|
@@ -376,36 +379,42 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
376
379
|
}
|
|
377
380
|
|
|
378
381
|
private void presentPresentationWithIdentifier(String presentationVendorId,
|
|
379
|
-
|
|
382
|
+
String contentId,
|
|
383
|
+
boolean isFullScreen,
|
|
380
384
|
CallbackContext callbackContext) {
|
|
381
385
|
presentationCallback = callbackContext;
|
|
382
386
|
Intent intent = PLYProductActivity.newIntent(cordova.getActivity());
|
|
383
387
|
intent.putExtra("presentationId", presentationVendorId);
|
|
384
388
|
intent.putExtra("contentId", contentId);
|
|
389
|
+
intent.putExtra("isFullScreen", isFullScreen);
|
|
385
390
|
cordova.getActivity().startActivity(intent);
|
|
386
391
|
}
|
|
387
392
|
|
|
388
393
|
private void presentProductWithIdentifier(String productVendorId,
|
|
389
394
|
String presentationVendorId,
|
|
390
395
|
String contentId,
|
|
396
|
+
boolean isFullScreen,
|
|
391
397
|
CallbackContext callbackContext) {
|
|
392
398
|
presentationCallback = callbackContext;
|
|
393
399
|
Intent intent = PLYProductActivity.newIntent(cordova.getActivity());
|
|
394
400
|
intent.putExtra("presentationId", presentationVendorId);
|
|
395
401
|
intent.putExtra("productId", productVendorId);
|
|
396
402
|
intent.putExtra("contentId", contentId);
|
|
403
|
+
intent.putExtra("isFullScreen", isFullScreen);
|
|
397
404
|
cordova.getActivity().startActivity(intent);
|
|
398
405
|
}
|
|
399
406
|
|
|
400
407
|
private void presentPlanWithIdentifier(String planVendorId,
|
|
401
408
|
String presentationVendorId,
|
|
402
409
|
String contentId,
|
|
410
|
+
boolean isFullScreen,
|
|
403
411
|
CallbackContext callbackContext) {
|
|
404
412
|
presentationCallback = callbackContext;
|
|
405
413
|
Intent intent = PLYProductActivity.newIntent(cordova.getActivity());
|
|
406
414
|
intent.putExtra("presentationId", presentationVendorId);
|
|
407
415
|
intent.putExtra("planId", planVendorId);
|
|
408
416
|
intent.putExtra("contentId", contentId);
|
|
417
|
+
intent.putExtra("isFullScreen", isFullScreen);
|
|
409
418
|
cordova.getActivity().startActivity(intent);
|
|
410
419
|
}
|
|
411
420
|
|
|
@@ -0,0 +1,6 @@
|
|
|
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>
|
|
@@ -0,0 +1,6 @@
|
|
|
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>
|
|
@@ -0,0 +1,7 @@
|
|
|
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>
|
package/src/ios/CDVPurchasely.m
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
NSInteger logLevel = [[command argumentAtIndex:3] intValue];
|
|
18
18
|
NSInteger runningMode = [[command argumentAtIndex:4] intValue];
|
|
19
19
|
|
|
20
|
+
[Purchasely setAppTechnology:PLYAppTechnologyCordova];
|
|
20
21
|
[Purchasely startWithAPIKey:apiKey appUserId:userId runningMode:runningMode eventDelegate:nil uiDelegate:nil paywallActionsInterceptor:nil logLevel:logLevel initialized:^(BOOL initialized, NSError * _Nullable error) {
|
|
21
22
|
if (error != nil) {
|
|
22
23
|
[self failureFor:command resultString: error.localizedDescription];
|
|
@@ -24,7 +25,6 @@
|
|
|
24
25
|
[self successFor:command resultBool:initialized];
|
|
25
26
|
}
|
|
26
27
|
}];
|
|
27
|
-
[Purchasely setAppTechnology:PLYAppTechnologyCordova];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
- (void)setLogLevel:(CDVInvokedUrlCommand*)command {
|
|
@@ -72,8 +72,10 @@
|
|
|
72
72
|
|
|
73
73
|
- (void)presentPresentationWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
74
74
|
NSString *presentationVendorId = [command argumentAtIndex:0];
|
|
75
|
+
NSString *contentId = [command argumentAtIndex:1];
|
|
76
|
+
BOOL isFullscreen = [[command argumentAtIndex:2] boolValue];
|
|
75
77
|
|
|
76
|
-
UIViewController *ctrl = [Purchasely presentationControllerWith:presentationVendorId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
78
|
+
UIViewController *ctrl = [Purchasely presentationControllerWith:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
77
79
|
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
78
80
|
[self successFor:command resultDict:resultDict];
|
|
79
81
|
}];
|
|
@@ -86,7 +88,10 @@
|
|
|
86
88
|
[navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
|
|
87
89
|
|
|
88
90
|
self.presentedPresentationViewController = navCtrl;
|
|
89
|
-
|
|
91
|
+
|
|
92
|
+
if (isFullscreen) {
|
|
93
|
+
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
94
|
+
}
|
|
90
95
|
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
91
96
|
}
|
|
92
97
|
}
|
|
@@ -94,8 +99,10 @@
|
|
|
94
99
|
- (void)presentPlanWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
95
100
|
NSString *planVendorId = [command argumentAtIndex:0];
|
|
96
101
|
NSString *presentationVendorId = [command argumentAtIndex:1];
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
NSString *contentId = [command argumentAtIndex:2];
|
|
103
|
+
BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
|
|
104
|
+
|
|
105
|
+
UIViewController *ctrl = [Purchasely planControllerFor:planVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
99
106
|
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
100
107
|
[self successFor:command resultDict:resultDict];
|
|
101
108
|
}];
|
|
@@ -109,6 +116,9 @@
|
|
|
109
116
|
|
|
110
117
|
self.presentedPresentationViewController = navCtrl;
|
|
111
118
|
|
|
119
|
+
if (isFullscreen) {
|
|
120
|
+
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
121
|
+
}
|
|
112
122
|
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
113
123
|
}
|
|
114
124
|
}
|
|
@@ -116,8 +126,10 @@
|
|
|
116
126
|
- (void)presentProductWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
117
127
|
NSString *productVendorId = [command argumentAtIndex:0];
|
|
118
128
|
NSString *presentationVendorId = [command argumentAtIndex:1];
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
NSString *contentId = [command argumentAtIndex:2];
|
|
130
|
+
BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
|
|
131
|
+
|
|
132
|
+
UIViewController *ctrl = [Purchasely productControllerFor:productVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
121
133
|
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
122
134
|
[self successFor:command resultDict:resultDict];
|
|
123
135
|
}];
|
|
@@ -131,6 +143,9 @@
|
|
|
131
143
|
|
|
132
144
|
self.presentedPresentationViewController = navCtrl;
|
|
133
145
|
|
|
146
|
+
if (isFullscreen) {
|
|
147
|
+
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
148
|
+
}
|
|
134
149
|
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
135
150
|
}
|
|
136
151
|
}
|
package/www/Purchasely.js
CHANGED
|
@@ -46,28 +46,16 @@ exports.synchronize = function () {
|
|
|
46
46
|
exec(() => {}, defaultError, 'Purchasely', 'synchronize', []);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
exports.presentPresentationWithIdentifier = function (presentationId, contentId, success, error) {
|
|
50
|
-
exec(success, error, 'Purchasely', 'presentPresentationWithIdentifier', [presentationId, contentId]);
|
|
49
|
+
exports.presentPresentationWithIdentifier = function (presentationId, contentId, isFullscreen, success, error) {
|
|
50
|
+
exec(success, error, 'Purchasely', 'presentPresentationWithIdentifier', [presentationId, contentId, isFullscreen]);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
exports.
|
|
54
|
-
exec(success, error, 'Purchasely', '
|
|
53
|
+
exports.presentProductWithIdentifier = function (productId, presentationId, contentId, isFullscreen, success, error) {
|
|
54
|
+
exec(success, error, 'Purchasely', 'presentProductWithIdentifier', [productId, presentationId, contentId, isFullscreen]);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
exports.
|
|
58
|
-
exec(success, error, 'Purchasely', '
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
exports.presentProductWithIdentifier = function (productId, presentationId, success, error) {
|
|
62
|
-
exec(success, error, 'Purchasely', 'presentProductWithIdentifier', [productId, presentationId, null]);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.presentPlanWithIdentifier = function (planId, presentationId, contentId, success, error) {
|
|
66
|
-
exec(success, error, 'Purchasely', 'presentPlanWithIdentifier', [planId, presentationId, contentId]);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.presentPlanWithIdentifier = function (planId, presentationId, success, error) {
|
|
70
|
-
exec(success, error, 'Purchasely', 'presentPlanWithIdentifier', [planId, presentationId, null]);
|
|
57
|
+
exports.presentPlanWithIdentifier = function (planId, presentationId, contentId, isFullscreen, success, error) {
|
|
58
|
+
exec(success, error, 'Purchasely', 'presentPlanWithIdentifier', [planId, presentationId, contentId, isFullscreen]);
|
|
71
59
|
};
|
|
72
60
|
|
|
73
61
|
exports.presentSubscriptions = function () {
|