@purchasely/cordova-plugin-purchasely 4.3.1 → 5.1.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/example/android.sh +1 -1
- package/example/package-lock.json +296 -1006
- package/example/package.json +3 -4
- package/example/www/js/index.js +74 -5
- package/package.json +1 -1
- package/plugin.xml +5 -3
- package/src/android/PLYProductActivity.kt +7 -12
- package/src/android/PurchaselyPlugin.kt +237 -13
- package/src/ios/CDVPurchasely+UserAttributes.h +35 -0
- package/src/ios/CDVPurchasely+UserAttributes.m +144 -0
- package/src/ios/CDVPurchasely.h +10 -1
- package/src/ios/CDVPurchasely.m +184 -11
- package/www/Purchasely.js +53 -17
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CDVPurchasely+UserAttributes.h
|
|
3
|
+
// Purchasely Cordova Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Florian HUET on 26/03/2025.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Cordova/CDVPlugin.h>
|
|
9
|
+
#import "CDVPurchasely.h"
|
|
10
|
+
|
|
11
|
+
@interface CDVPurchasely (UserAttributes) {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
- (void)onUserAttributeSetWithKey:(NSString * _Nonnull)key
|
|
16
|
+
type:(enum PLYUserAttributeType)type
|
|
17
|
+
value:(id _Nullable)value
|
|
18
|
+
source:(enum PLYUserAttributeSource)source;
|
|
19
|
+
|
|
20
|
+
- (void)onUserAttributeRemovedWithKey:(NSString * _Nonnull)key
|
|
21
|
+
source:(enum PLYUserAttributeSource)source;
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
@interface PLYUserAttributeTypeHelper : NSObject
|
|
26
|
+
|
|
27
|
+
+ (NSString *_Nullable)stringFromUserAttributeType:(PLYUserAttributeType)type;
|
|
28
|
+
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@interface PLYUserAttributeSourceHelper : NSObject
|
|
32
|
+
|
|
33
|
+
+ (NSString *_Nullable)stringFromUserAttributeSource:(PLYUserAttributeSource)source;
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CDVPurchasely+UserAttributes.m
|
|
3
|
+
// Purchasely Cordova Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Florian HUET on 26/03/2025.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Purchasely/Purchasely-Swift.h>
|
|
9
|
+
#import "CDVPurchasely+UserAttributes.h"
|
|
10
|
+
#import "Purchasely_Hybrid.h"
|
|
11
|
+
|
|
12
|
+
@implementation CDVPurchasely (UserAttributes)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
- (void)onUserAttributeSetWithKey:(NSString * _Nonnull)key
|
|
16
|
+
type:(enum PLYUserAttributeType)type
|
|
17
|
+
value:(id _Nullable)value
|
|
18
|
+
source:(enum PLYUserAttributeSource)source {
|
|
19
|
+
NSDictionary *attributeDic = [self dictionaryFromUserAttributeWithKey:key type:type value:value source:source];
|
|
20
|
+
|
|
21
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:attributeDic];
|
|
22
|
+
|
|
23
|
+
[pluginResult setKeepCallbackAsBool:YES];
|
|
24
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.attributeCommand.callbackId];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (void)onUserAttributeRemovedWithKey:(NSString * _Nonnull)key
|
|
28
|
+
source:(enum PLYUserAttributeSource)source {
|
|
29
|
+
NSString *sourceString = [PLYUserAttributeSourceHelper stringFromUserAttributeSource:source];
|
|
30
|
+
|
|
31
|
+
NSMutableDictionary<NSString *, id> *attributeDic = [@{
|
|
32
|
+
@"action": @"remove",
|
|
33
|
+
@"key": key,
|
|
34
|
+
@"source": sourceString
|
|
35
|
+
} mutableCopy];
|
|
36
|
+
|
|
37
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:attributeDic];
|
|
38
|
+
|
|
39
|
+
[pluginResult setKeepCallbackAsBool:YES];
|
|
40
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.attributeCommand.callbackId];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (NSDictionary<NSString *, id> *)dictionaryFromUserAttributeWithKey:(NSString * _Nonnull)key
|
|
44
|
+
type:(enum PLYUserAttributeType)type
|
|
45
|
+
value:(id _Nullable)value
|
|
46
|
+
source:(enum PLYUserAttributeSource)source {
|
|
47
|
+
NSString *typeString = [PLYUserAttributeTypeHelper stringFromUserAttributeType:type];
|
|
48
|
+
NSString *sourceString = [PLYUserAttributeSourceHelper stringFromUserAttributeSource:source];
|
|
49
|
+
|
|
50
|
+
NSMutableDictionary<NSString *, id> *attributeDic = [@{
|
|
51
|
+
@"action": @"add",
|
|
52
|
+
@"key": key,
|
|
53
|
+
@"type": typeString,
|
|
54
|
+
@"source": sourceString
|
|
55
|
+
} mutableCopy];
|
|
56
|
+
|
|
57
|
+
if (value) {
|
|
58
|
+
switch (type) {
|
|
59
|
+
case PLYUserAttributeTypeString:
|
|
60
|
+
if ([value isKindOfClass:[NSString class]]) {
|
|
61
|
+
attributeDic[@"value"] = value;
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case PLYUserAttributeTypeBool:
|
|
65
|
+
if ([value isKindOfClass:[NSNumber class]]) {
|
|
66
|
+
attributeDic[@"value"] = @([(NSNumber *)value boolValue]);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case PLYUserAttributeTypeInt:
|
|
70
|
+
if ([value isKindOfClass:[NSNumber class]]) {
|
|
71
|
+
attributeDic[@"value"] = @([(NSNumber *)value intValue]);
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case PLYUserAttributeTypeDouble:
|
|
75
|
+
if ([value isKindOfClass:[NSNumber class]]) {
|
|
76
|
+
attributeDic[@"value"] = @([(NSNumber *)value doubleValue]);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case PLYUserAttributeTypeDate:
|
|
80
|
+
if ([value isKindOfClass:[NSDate class]]) {
|
|
81
|
+
attributeDic[@"value"] = [(NSDate *)value description]; // Convert to string
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case PLYUserAttributeTypeStringArray:
|
|
85
|
+
if ([value isKindOfClass:[NSArray class]]) {
|
|
86
|
+
attributeDic[@"value"] = value; // Ensure it's an NSArray of NSString
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case PLYUserAttributeTypeIntArray:
|
|
90
|
+
case PLYUserAttributeTypeDoubleArray:
|
|
91
|
+
case PLYUserAttributeTypeBoolArray:
|
|
92
|
+
if ([value isKindOfClass:[NSArray class]]) {
|
|
93
|
+
attributeDic[@"value"] = value; // Ensure it's an NSArray of NSNumber
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case PLYUserAttributeTypeDictionary:
|
|
97
|
+
if ([value isKindOfClass:[NSDictionary class]]) {
|
|
98
|
+
attributeDic[@"value"] = value; // Ensure it's an NSDictionary
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
attributeDic[@"value"] = @"unknown";
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return [attributeDic copy];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@end
|
|
112
|
+
|
|
113
|
+
@implementation PLYUserAttributeTypeHelper
|
|
114
|
+
|
|
115
|
+
+ (NSString *_Nullable)stringFromUserAttributeType:(PLYUserAttributeType)type {
|
|
116
|
+
switch (type) {
|
|
117
|
+
case PLYUserAttributeTypeString: return @"string";
|
|
118
|
+
case PLYUserAttributeTypeBool: return @"bool";
|
|
119
|
+
case PLYUserAttributeTypeInt: return @"int";
|
|
120
|
+
case PLYUserAttributeTypeDouble: return @"double";
|
|
121
|
+
case PLYUserAttributeTypeDate: return @"date";
|
|
122
|
+
case PLYUserAttributeTypeStringArray: return @"stringArray";
|
|
123
|
+
case PLYUserAttributeTypeIntArray: return @"intArray";
|
|
124
|
+
case PLYUserAttributeTypeDoubleArray: return @"doubleArray";
|
|
125
|
+
case PLYUserAttributeTypeBoolArray: return @"boolArray";
|
|
126
|
+
case PLYUserAttributeTypeDictionary: return @"dictionary";
|
|
127
|
+
case PLYUserAttributeTypeUnknown: return @"unknown";
|
|
128
|
+
default: return @"invalid";
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@end
|
|
133
|
+
|
|
134
|
+
@implementation PLYUserAttributeSourceHelper
|
|
135
|
+
|
|
136
|
+
+ (NSString *_Nullable)stringFromUserAttributeSource:(PLYUserAttributeSource)source {
|
|
137
|
+
switch (source) {
|
|
138
|
+
case PLYUserAttributeSourcePurchasely: return @"purchasely";
|
|
139
|
+
case PLYUserAttributeSourceClient: return @"client";
|
|
140
|
+
default: return @"unknown";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@end
|
package/src/ios/CDVPurchasely.h
CHANGED
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
#import <Cordova/CDVPlugin.h>
|
|
9
9
|
#import <Purchasely/Purchasely-Swift.h>
|
|
10
10
|
|
|
11
|
-
@interface CDVPurchasely<PLYEventDelegate> : CDVPlugin {
|
|
11
|
+
@interface CDVPurchasely<PLYEventDelegate, PLYUserAttributeDelegate> : CDVPlugin {
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
@property (nonatomic, retain) UIViewController* presentedPresentationViewController;
|
|
15
15
|
|
|
16
16
|
@property CDVInvokedUrlCommand* purchasedCommand;
|
|
17
17
|
@property CDVInvokedUrlCommand* eventCommand;
|
|
18
|
+
@property CDVInvokedUrlCommand* attributeCommand;
|
|
18
19
|
|
|
19
20
|
@property (nonatomic) NSMutableArray<PLYPresentation *> *presentationsLoaded;
|
|
20
21
|
@property (nonatomic, assign) Boolean shouldReopenPaywall;
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
- (void)productWithIdentifier:(CDVInvokedUrlCommand*)command;
|
|
47
48
|
- (void)planWithIdentifier:(CDVInvokedUrlCommand*)command;
|
|
48
49
|
- (void)userSubscriptions:(CDVInvokedUrlCommand*)command;
|
|
50
|
+
- (void)userSubscriptionsHistory:(CDVInvokedUrlCommand*)command;
|
|
49
51
|
- (void)addEventsListener:(CDVInvokedUrlCommand*)command;
|
|
50
52
|
- (void)removeEventsListener:(CDVInvokedUrlCommand*)command;
|
|
51
53
|
- (void)isDeeplinkHandled:(CDVInvokedUrlCommand*)command;
|
|
@@ -55,17 +57,24 @@
|
|
|
55
57
|
- (void)hidePresentation:(CDVInvokedUrlCommand*)command;
|
|
56
58
|
- (void)showPresentation:(CDVInvokedUrlCommand*)command;
|
|
57
59
|
- (void)userDidConsumeSubscriptionContent:(CDVInvokedUrlCommand*)command;
|
|
60
|
+
- (void)setUserAttributeWithStringArray:(CDVInvokedUrlCommand*)command;
|
|
61
|
+
- (void)setUserAttributeWithIntArray:(CDVInvokedUrlCommand*)command;
|
|
62
|
+
- (void)setUserAttributeWithDoubleArray:(CDVInvokedUrlCommand*)command;
|
|
63
|
+
- (void)setUserAttributeWithBooleanArray:(CDVInvokedUrlCommand*)command;
|
|
58
64
|
- (void)setUserAttributeWithString:(CDVInvokedUrlCommand*)command;
|
|
59
65
|
- (void)setUserAttributeWithBoolean:(CDVInvokedUrlCommand*)command;
|
|
60
66
|
- (void)setUserAttributeWithInt:(CDVInvokedUrlCommand*)command;
|
|
67
|
+
- (void)setUserAttributeWithDouble:(CDVInvokedUrlCommand*)command;
|
|
61
68
|
- (void)setUserAttributeWithDate:(CDVInvokedUrlCommand*)command;
|
|
62
69
|
- (void)userAttribute:(CDVInvokedUrlCommand*)command;
|
|
63
70
|
- (void)clearUserAttribute:(CDVInvokedUrlCommand*)command;
|
|
64
71
|
- (void)clearUserAttributes:(CDVInvokedUrlCommand*)command;
|
|
72
|
+
- (void)clearBuiltInAttributes:(CDVInvokedUrlCommand*)command;
|
|
65
73
|
- (void)fetchPresentation:(CDVInvokedUrlCommand*)command;
|
|
66
74
|
- (void)presentPresentation:(CDVInvokedUrlCommand*)command;
|
|
67
75
|
- (void)signPromotionalOffer:(CDVInvokedUrlCommand*)command;
|
|
68
76
|
- (void)isEligibleForIntroOffer:(CDVInvokedUrlCommand*)command;
|
|
69
77
|
- (void)setThemeMode:(CDVInvokedUrlCommand*)command;
|
|
78
|
+
- (void)addUserAttributeListener:(CDVInvokedUrlCommand*)command;
|
|
70
79
|
|
|
71
80
|
@end
|
package/src/ios/CDVPurchasely.m
CHANGED
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
- (void)userLogout:(CDVInvokedUrlCommand*)command {
|
|
65
|
-
[Purchasely userLogout];
|
|
65
|
+
[Purchasely userLogout:YES];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
- (void)setThemeMode:(CDVInvokedUrlCommand *)command {
|
|
@@ -72,9 +72,87 @@
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
- (void)setAttribute:(CDVInvokedUrlCommand*)command {
|
|
75
|
-
|
|
75
|
+
NSNumber *attributeNumber = [command argumentAtIndex:0];
|
|
76
76
|
NSString *value = [command argumentAtIndex:1];
|
|
77
77
|
|
|
78
|
+
if (attributeNumber == nil || value == nil) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
NSInteger rawAttribute = [attributeNumber integerValue];
|
|
83
|
+
PLYAttribute *attribute = nil;
|
|
84
|
+
|
|
85
|
+
switch (rawAttribute) {
|
|
86
|
+
case CordovaPLYAttributeFirebaseAppInstanceId:
|
|
87
|
+
attribute = PLYAttributeFirebaseAppInstanceId;
|
|
88
|
+
break;
|
|
89
|
+
case CordovaPLYAttributeAirshipChannelId:
|
|
90
|
+
attribute = PLYAttributeAirshipChannelId;
|
|
91
|
+
break;
|
|
92
|
+
case CordovaPLYAttributeAirshipUserId:
|
|
93
|
+
attribute = PLYAttributeAirshipUserId;
|
|
94
|
+
break;
|
|
95
|
+
case CordovaPLYAttributeBatchInstallationId:
|
|
96
|
+
attribute = PLYAttributeBatchInstallationId;
|
|
97
|
+
break;
|
|
98
|
+
case CordovaPLYAttributeAdjustId:
|
|
99
|
+
attribute = PLYAttributeAdjustId;
|
|
100
|
+
break;
|
|
101
|
+
case CordovaPLYAttributeAppsflyerId:
|
|
102
|
+
attribute = PLYAttributeAppsflyerId;
|
|
103
|
+
break;
|
|
104
|
+
case CordovaPLYAttributeMixpanelDistinctId:
|
|
105
|
+
attribute = PLYAttributeMixpanelDistinctId;
|
|
106
|
+
break;
|
|
107
|
+
case CordovaPLYAttributeCleverTapId:
|
|
108
|
+
attribute = PLYAttributeClevertapId;
|
|
109
|
+
break;
|
|
110
|
+
case CordovaPLYAttributeSendinblueUserEmail:
|
|
111
|
+
attribute = PLYAttributeSendinblueUserEmail;
|
|
112
|
+
break;
|
|
113
|
+
case CordovaPLYAttributeIterableUserEmail:
|
|
114
|
+
attribute = PLYAttributeIterableUserEmail;
|
|
115
|
+
break;
|
|
116
|
+
case CordovaPLYAttributeIterableUserId:
|
|
117
|
+
attribute = PLYAttributeIterableUserId;
|
|
118
|
+
break;
|
|
119
|
+
case CordovaPLYAttributeAtInternetIdClient:
|
|
120
|
+
attribute = PLYAttributeAtInternetIdClient;
|
|
121
|
+
break;
|
|
122
|
+
case CordovaPLYAttributeMParticleUserId:
|
|
123
|
+
attribute = PLYAttributeMParticleUserId;
|
|
124
|
+
break;
|
|
125
|
+
case CordovaPLYAttributeCustomerioUserId:
|
|
126
|
+
attribute = PLYAttributeCustomerioUserId;
|
|
127
|
+
break;
|
|
128
|
+
case CordovaPLYAttributeCustomerioUserEmail:
|
|
129
|
+
attribute = PLYAttributeCustomerioUserEmail;
|
|
130
|
+
break;
|
|
131
|
+
case CordovaPLYAttributeBranchUserDeveloperIdentity:
|
|
132
|
+
attribute = PLYAttributeBranchUserDeveloperIdentity;
|
|
133
|
+
break;
|
|
134
|
+
case CordovaPLYAttributeAmplitudeUserId:
|
|
135
|
+
attribute = PLYAttributeAmplitudeUserId;
|
|
136
|
+
break;
|
|
137
|
+
case CordovaPLYAttributeAmplitudeDeviceId:
|
|
138
|
+
attribute = PLYAttributeAmplitudeDeviceId;
|
|
139
|
+
break;
|
|
140
|
+
case CordovaPLYAttributeMoengageUniqueId:
|
|
141
|
+
attribute = PLYAttributeMoengageUniqueId;
|
|
142
|
+
break;
|
|
143
|
+
case CordovaPLYAttributeOneSignalExternalId:
|
|
144
|
+
attribute = PLYAttributeOneSignalExternalId;
|
|
145
|
+
break;
|
|
146
|
+
case CordovaPLYAttributeBatchCustomUserId:
|
|
147
|
+
attribute = PLYAttributeBatchCustomUserId;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if (attribute == nil) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
78
156
|
[Purchasely setAttribute:attribute value:value];
|
|
79
157
|
}
|
|
80
158
|
|
|
@@ -120,7 +198,7 @@
|
|
|
120
198
|
if (isFullscreen) {
|
|
121
199
|
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
122
200
|
}
|
|
123
|
-
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
201
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
|
|
124
202
|
}
|
|
125
203
|
}
|
|
126
204
|
|
|
@@ -146,7 +224,7 @@
|
|
|
146
224
|
if (isFullscreen) {
|
|
147
225
|
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
148
226
|
}
|
|
149
|
-
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
227
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
|
|
150
228
|
}
|
|
151
229
|
}
|
|
152
230
|
|
|
@@ -173,7 +251,7 @@
|
|
|
173
251
|
if (isFullscreen) {
|
|
174
252
|
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
175
253
|
}
|
|
176
|
-
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
254
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
|
|
177
255
|
}
|
|
178
256
|
}
|
|
179
257
|
|
|
@@ -200,7 +278,7 @@
|
|
|
200
278
|
if (isFullscreen) {
|
|
201
279
|
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
202
280
|
}
|
|
203
|
-
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
281
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage from:nil];
|
|
204
282
|
}
|
|
205
283
|
}
|
|
206
284
|
|
|
@@ -209,7 +287,7 @@
|
|
|
209
287
|
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
210
288
|
ctrl.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:navCtrl action:@selector(close)];
|
|
211
289
|
|
|
212
|
-
[Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList];
|
|
290
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList from:nil];
|
|
213
291
|
}
|
|
214
292
|
|
|
215
293
|
- (void)purchaseWithPlanVendorId:(CDVInvokedUrlCommand*)command {
|
|
@@ -346,6 +424,20 @@
|
|
|
346
424
|
}];
|
|
347
425
|
}
|
|
348
426
|
|
|
427
|
+
- (void)userSubscriptionsHistory:(CDVInvokedUrlCommand*)command {
|
|
428
|
+
[Purchasely userSubscriptionsHistory:false
|
|
429
|
+
success:^(NSArray<PLYSubscription *> * _Nullable subscriptions) {
|
|
430
|
+
NSMutableArray *result = [NSMutableArray new];
|
|
431
|
+
for (PLYSubscription *subscription in subscriptions) {
|
|
432
|
+
[result addObject:subscription.asDictionary];
|
|
433
|
+
}
|
|
434
|
+
[self successFor:command resultArray:result];
|
|
435
|
+
}
|
|
436
|
+
failure:^(NSError * _Nonnull error) {
|
|
437
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
438
|
+
}];
|
|
439
|
+
}
|
|
440
|
+
|
|
349
441
|
- (void)addEventsListener:(CDVInvokedUrlCommand*)command {
|
|
350
442
|
[Purchasely setEventDelegate:self];
|
|
351
443
|
self.eventCommand = command;
|
|
@@ -356,6 +448,16 @@
|
|
|
356
448
|
self.eventCommand = nil;
|
|
357
449
|
}
|
|
358
450
|
|
|
451
|
+
- (void)removeUserAttributeListener:(CDVInvokedUrlCommand*)command {
|
|
452
|
+
[Purchasely setUserAttributeDelegate:nil];
|
|
453
|
+
self.attributeCommand = nil;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
- (void)addUserAttributeListener:(CDVInvokedUrlCommand*)command {
|
|
457
|
+
[Purchasely setUserAttributeDelegate:self];
|
|
458
|
+
self.attributeCommand = command;
|
|
459
|
+
}
|
|
460
|
+
|
|
359
461
|
- (void)isDeeplinkHandled:(CDVInvokedUrlCommand*)command {
|
|
360
462
|
NSString *deeplinkString = [command argumentAtIndex:0];
|
|
361
463
|
NSURL *deeplink = [NSURL URLWithString:deeplinkString];
|
|
@@ -555,7 +657,7 @@
|
|
|
555
657
|
if (self.presentedPresentationViewController && self.shouldReopenPaywall) {
|
|
556
658
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
|
557
659
|
self.shouldReopenPaywall = NO;
|
|
558
|
-
[Purchasely showController:self.presentedPresentationViewController type:PLYUIControllerTypeProductPage];
|
|
660
|
+
[Purchasely showController:self.presentedPresentationViewController type:PLYUIControllerTypeProductPage from:nil];
|
|
559
661
|
});
|
|
560
662
|
}
|
|
561
663
|
});
|
|
@@ -565,6 +667,48 @@
|
|
|
565
667
|
[Purchasely userDidConsumeSubscriptionContent];
|
|
566
668
|
}
|
|
567
669
|
|
|
670
|
+
- (void)setUserAttributeWithStringArray:(CDVInvokedUrlCommand*)command {
|
|
671
|
+
NSString *key = [command argumentAtIndex:0];
|
|
672
|
+
NSArray<NSString *> *array = [command argumentAtIndex:1];
|
|
673
|
+
[Purchasely setUserAttributeWithStringArray:array forKey:key];
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
- (void)setUserAttributeWithBooleanArray:(CDVInvokedUrlCommand*)command {
|
|
677
|
+
NSString *key = [command argumentAtIndex:0];
|
|
678
|
+
NSArray *values = [command argumentAtIndex:1];
|
|
679
|
+
|
|
680
|
+
NSMutableArray<NSNumber *> *boolArray = [NSMutableArray array];
|
|
681
|
+
for (id value in values) {
|
|
682
|
+
[boolArray addObject:@([value boolValue])];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
[Purchasely setUserAttributeWithBoolArray:boolArray forKey:key];
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
- (void)setUserAttributeWithIntArray:(CDVInvokedUrlCommand*)command {
|
|
689
|
+
NSString *key = [command argumentAtIndex:0];
|
|
690
|
+
NSArray *values = [command argumentAtIndex:1];
|
|
691
|
+
|
|
692
|
+
NSMutableArray<NSNumber *> *intArray = [NSMutableArray array];
|
|
693
|
+
for (id val in values) {
|
|
694
|
+
[intArray addObject:@([val intValue])];
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
[Purchasely setUserAttributeWithIntArray:intArray forKey:key];
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
- (void)setUserAttributeWithDoubleArray:(CDVInvokedUrlCommand*)command {
|
|
701
|
+
NSString *key = [command argumentAtIndex:0];
|
|
702
|
+
NSArray *values = [command argumentAtIndex:1];
|
|
703
|
+
|
|
704
|
+
NSMutableArray<NSNumber *> *doubleArray = [NSMutableArray array];
|
|
705
|
+
for (id val in values) {
|
|
706
|
+
[doubleArray addObject:@([val doubleValue])];
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
[Purchasely setUserAttributeWithDoubleArray:doubleArray forKey:key];
|
|
710
|
+
}
|
|
711
|
+
|
|
568
712
|
- (void)setUserAttributeWithString:(CDVInvokedUrlCommand*)command {
|
|
569
713
|
NSString *key = [command argumentAtIndex:0];
|
|
570
714
|
NSString *value = [command argumentAtIndex:1];
|
|
@@ -636,6 +780,10 @@
|
|
|
636
780
|
[Purchasely clearUserAttributes];
|
|
637
781
|
}
|
|
638
782
|
|
|
783
|
+
- (void)clearBuiltInAttributes:(CDVInvokedUrlCommand*)command {
|
|
784
|
+
[Purchasely clearBuiltInAttributes];
|
|
785
|
+
}
|
|
786
|
+
|
|
639
787
|
- (void)fetchPresentation:(CDVInvokedUrlCommand*)command {
|
|
640
788
|
NSString *placementId = [command argumentAtIndex:0];
|
|
641
789
|
NSString *presentationId = [command argumentAtIndex:1];
|
|
@@ -654,7 +802,7 @@
|
|
|
654
802
|
if (self.purchaseResolve != nil){
|
|
655
803
|
[self successFor:self.purchaseResolve resultDict:[self resultDictionaryForPresentationController:result plan:plan]];
|
|
656
804
|
}
|
|
657
|
-
}];
|
|
805
|
+
} loadedCompletion:nil];
|
|
658
806
|
} else {
|
|
659
807
|
[Purchasely fetchPresentationWith:presentationId contentId: contentId fetchCompletion:^(PLYPresentation * _Nullable presentation, NSError * _Nullable error) {
|
|
660
808
|
if (error != nil) {
|
|
@@ -667,7 +815,7 @@
|
|
|
667
815
|
if (self.purchaseResolve != nil) {
|
|
668
816
|
[self successFor:self.purchaseResolve resultDict:[self resultDictionaryForPresentationController:result plan:plan]];
|
|
669
817
|
}
|
|
670
|
-
}];
|
|
818
|
+
} loadedCompletion:nil];
|
|
671
819
|
}
|
|
672
820
|
});
|
|
673
821
|
}
|
|
@@ -712,7 +860,7 @@
|
|
|
712
860
|
[Purchasely closeDisplayedPresentation];
|
|
713
861
|
self.presentedPresentationViewController = presentationLoaded.controller;
|
|
714
862
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
|
715
|
-
[Purchasely showController:presentationLoaded.controller type: PLYUIControllerTypeProductPage];
|
|
863
|
+
[Purchasely showController:presentationLoaded.controller type: PLYUIControllerTypeProductPage from:nil];
|
|
716
864
|
});
|
|
717
865
|
}
|
|
718
866
|
});
|
|
@@ -897,4 +1045,29 @@
|
|
|
897
1045
|
}
|
|
898
1046
|
|
|
899
1047
|
|
|
1048
|
+
// WARNING: This enum must be strictly identical to the one in the JS side (Purchasely.js).
|
|
1049
|
+
typedef NS_ENUM(NSInteger, CordovaPLYAttribute) {
|
|
1050
|
+
CordovaPLYAttributeFirebaseAppInstanceId,
|
|
1051
|
+
CordovaPLYAttributeAirshipChannelId,
|
|
1052
|
+
CordovaPLYAttributeAirshipUserId,
|
|
1053
|
+
CordovaPLYAttributeBatchInstallationId,
|
|
1054
|
+
CordovaPLYAttributeAdjustId,
|
|
1055
|
+
CordovaPLYAttributeAppsflyerId,
|
|
1056
|
+
CordovaPLYAttributeMixpanelDistinctId,
|
|
1057
|
+
CordovaPLYAttributeCleverTapId,
|
|
1058
|
+
CordovaPLYAttributeSendinblueUserEmail,
|
|
1059
|
+
CordovaPLYAttributeIterableUserEmail,
|
|
1060
|
+
CordovaPLYAttributeIterableUserId,
|
|
1061
|
+
CordovaPLYAttributeAtInternetIdClient,
|
|
1062
|
+
CordovaPLYAttributeMParticleUserId,
|
|
1063
|
+
CordovaPLYAttributeCustomerioUserId,
|
|
1064
|
+
CordovaPLYAttributeCustomerioUserEmail,
|
|
1065
|
+
CordovaPLYAttributeBranchUserDeveloperIdentity,
|
|
1066
|
+
CordovaPLYAttributeAmplitudeUserId,
|
|
1067
|
+
CordovaPLYAttributeAmplitudeDeviceId,
|
|
1068
|
+
CordovaPLYAttributeMoengageUniqueId,
|
|
1069
|
+
CordovaPLYAttributeOneSignalExternalId,
|
|
1070
|
+
CordovaPLYAttributeBatchCustomUserId
|
|
1071
|
+
};
|
|
1072
|
+
|
|
900
1073
|
@end
|
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 = "
|
|
8
|
+
cordovaSdkVersion = "5.1.0";
|
|
9
9
|
}
|
|
10
10
|
exec(success, error, 'Purchasely', 'start', [apiKey, stores, storekit1, userId, logLevel, runningMode, cordovaSdkVersion]);
|
|
11
11
|
};
|
|
@@ -14,6 +14,14 @@ exports.addEventsListener = function (success, error) {
|
|
|
14
14
|
exec(success, error, 'Purchasely', 'addEventsListener', []);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
exports.addUserAttributeListener = function(success, error) {
|
|
18
|
+
exec(success, error, 'Purchasely', 'addUserAttributeListener', []);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.removeUserAttributeListener = function () {
|
|
22
|
+
exec(() => {}, defaultError, 'Purchasely', 'removeUserAttributeListener', []);
|
|
23
|
+
};
|
|
24
|
+
|
|
17
25
|
exports.removeEventsListener = function () {
|
|
18
26
|
exec(() => {}, defaultError, 'Purchasely', 'removeEventsListener', []);
|
|
19
27
|
};
|
|
@@ -130,6 +138,10 @@ exports.userSubscriptions = function (success, error) {
|
|
|
130
138
|
exec(success, defaultError, 'Purchasely', 'userSubscriptions', []);
|
|
131
139
|
};
|
|
132
140
|
|
|
141
|
+
exports.userSubscriptionsHistory = function (success, error) {
|
|
142
|
+
exec(success, defaultError, 'Purchasely', 'userSubscriptionsHistory', []);
|
|
143
|
+
};
|
|
144
|
+
|
|
133
145
|
exports.setLanguage = function (language) {
|
|
134
146
|
exec(() => {}, defaultError, 'Purchasely', 'setLanguage', [language]);
|
|
135
147
|
};
|
|
@@ -166,6 +178,22 @@ exports.setUserAttributeWithDate = function (key, value) {
|
|
|
166
178
|
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithDate', [key, value]);
|
|
167
179
|
};
|
|
168
180
|
|
|
181
|
+
exports.setUserAttributeWithStringArray = function (key, value) {
|
|
182
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithStringArray', [key, value]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
exports.setUserAttributeWithIntArray = function (key, value) {
|
|
186
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithIntArray', [key, value]);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
exports.setUserAttributeWithDoubleArray = function (key, value) {
|
|
190
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithDoubleArray', [key, value]);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
exports.setUserAttributeWithBooleanArray = function (key, value) {
|
|
194
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithBooleanArray', [key, value]);
|
|
195
|
+
}
|
|
196
|
+
|
|
169
197
|
exports.userAttribute = function (key, success, error) {
|
|
170
198
|
exec(success, error, 'Purchasely', 'userAttribute', [key]);
|
|
171
199
|
};
|
|
@@ -178,6 +206,10 @@ exports.clearUserAttributes = function () {
|
|
|
178
206
|
exec(() => {}, defaultError, 'Purchasely', 'clearUserAttributes', []);
|
|
179
207
|
};
|
|
180
208
|
|
|
209
|
+
exports.clearBuiltInAttributes = function () {
|
|
210
|
+
exec(() => {}, defaultError, 'Purchasely', 'clearBuiltInAttributes', []);
|
|
211
|
+
}
|
|
212
|
+
|
|
181
213
|
exports.isEligibleForIntroOffer = function (planId, success, error) {
|
|
182
214
|
exec(success, error, 'Purchasely', 'isEligibleForIntroOffer', [planId]);
|
|
183
215
|
};
|
|
@@ -204,22 +236,21 @@ exports.Attribute = {
|
|
|
204
236
|
BATCH_INSTALLATION_ID: 3,
|
|
205
237
|
ADJUST_ID: 4,
|
|
206
238
|
APPSFLYER_ID: 5,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
BATCH_CUSTOM_USER_ID: 21,
|
|
239
|
+
MIXPANEL_DISTINCT_ID: 6,
|
|
240
|
+
CLEVER_TAP_ID: 7,
|
|
241
|
+
SENDINBLUE_USER_EMAIL: 8,
|
|
242
|
+
ITERABLE_USER_EMAIL: 9,
|
|
243
|
+
ITERABLE_USER_ID: 10,
|
|
244
|
+
AT_INTERNET_ID_CLIENT: 11,
|
|
245
|
+
MPARTICLE_USER_ID: 12,
|
|
246
|
+
CUSTOMERIO_USER_ID: 13,
|
|
247
|
+
CUSTOMERIO_USER_EMAIL: 14,
|
|
248
|
+
BRANCH_USER_DEVELOPER_IDENTITY: 15,
|
|
249
|
+
AMPLITUDE_USER_ID: 16,
|
|
250
|
+
AMPLITUDE_DEVICE_ID: 17,
|
|
251
|
+
MOENGAGE_UNIQUE_ID: 18,
|
|
252
|
+
ONESIGNAL_EXTERNAL_ID: 19,
|
|
253
|
+
BATCH_CUSTOM_USER_ID: 20,
|
|
223
254
|
}
|
|
224
255
|
|
|
225
256
|
exports.PurchaseResult = {
|
|
@@ -266,3 +297,8 @@ exports.ThemeMode = {
|
|
|
266
297
|
dark: 1,
|
|
267
298
|
system: 2
|
|
268
299
|
}
|
|
300
|
+
|
|
301
|
+
exports.UserAttributeAction = {
|
|
302
|
+
ADD: 'add',
|
|
303
|
+
REMOVE: 'remove'
|
|
304
|
+
}
|