Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 0b0dc72

Browse files
committed
Release v1.3.5-beta.0
1 parent 8efdf6c commit 0b0dc72

17 files changed

+242
-10
lines changed

Glassfy.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Glassfy"
3-
s.version = "1.3.4"
3+
s.version = "1.3.5-beta.0"
44
s.summary = "Subscription and in-app-purchase service."
55
s.license = { :type => 'MIT', :file => 'LICENSE' }
66
s.source = { :git => "https://github.com/glassfy/ios-sdk.git", :tag => s.version.to_s }

Glassfy.xcodeproj/project.pbxproj

+14-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
81D8D49A258B7193006BFE51 /* Glassfy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168309F258B6D9C00565968 /* Glassfy.framework */; };
101101
81E1DC3225933FC7003B5EBD /* SKPayment+GYEncode.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E1DC3025933FC7003B5EBD /* SKPayment+GYEncode.h */; settings = {ATTRIBUTES = (Private, ); }; };
102102
81E1DC3325933FC7003B5EBD /* SKPayment+GYEncode.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E1DC3125933FC7003B5EBD /* SKPayment+GYEncode.m */; };
103+
81E5B8942912C87600D134E9 /* GYAttributionItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E5B8932912C87600D134E9 /* GYAttributionItem.m */; };
104+
81E5B8962912C88400D134E9 /* GYAttributionItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E5B8952912C88400D134E9 /* GYAttributionItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
105+
81E5B89A2912CEBC00D134E9 /* GYAttributionItem+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E5B8972912CE9700D134E9 /* GYAttributionItem+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
103106
81EFB54425A772D900706FCB /* GYAPIPermissionsResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 81EFB54225A772D900706FCB /* GYAPIPermissionsResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
104107
81EFB54525A772D900706FCB /* GYAPIPermissionsResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 81EFB54325A772D900706FCB /* GYAPIPermissionsResponse.m */; };
105108
81EFB54B25A772F200706FCB /* GYPermission.m in Sources */ = {isa = PBXBuildFile; fileRef = 81EFB54925A772F200706FCB /* GYPermission.m */; };
@@ -213,6 +216,9 @@
213216
81D8D499258B7193006BFE51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
214217
81E1DC3025933FC7003B5EBD /* SKPayment+GYEncode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SKPayment+GYEncode.h"; sourceTree = "<group>"; };
215218
81E1DC3125933FC7003B5EBD /* SKPayment+GYEncode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SKPayment+GYEncode.m"; sourceTree = "<group>"; };
219+
81E5B8932912C87600D134E9 /* GYAttributionItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYAttributionItem.m; sourceTree = "<group>"; };
220+
81E5B8952912C88400D134E9 /* GYAttributionItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYAttributionItem.h; path = Public/GYAttributionItem.h; sourceTree = "<group>"; };
221+
81E5B8972912CE9700D134E9 /* GYAttributionItem+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GYAttributionItem+Private.h"; sourceTree = "<group>"; };
216222
81EFB54225A772D900706FCB /* GYAPIPermissionsResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYAPIPermissionsResponse.h; sourceTree = "<group>"; };
217223
81EFB54325A772D900706FCB /* GYAPIPermissionsResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYAPIPermissionsResponse.m; sourceTree = "<group>"; };
218224
81EFB54925A772F200706FCB /* GYPermission.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYPermission.m; sourceTree = "<group>"; };
@@ -308,6 +314,8 @@
308314
children = (
309315
81951CD026443F65003901F1 /* Glassfy.h */,
310316
817A1C75258CE0A200D1BA10 /* Glassfy.m */,
317+
81E5B8952912C88400D134E9 /* GYAttributionItem.h */,
318+
81E5B8932912C87600D134E9 /* GYAttributionItem.m */,
311319
81951CD526443F94003901F1 /* GYOfferings.h */,
312320
810F6FB225E50CFF00D3009E /* GYOfferings.m */,
313321
81951CD426443F94003901F1 /* GYOffering.h */,
@@ -371,6 +379,7 @@
371379
81C9AF672805D2F3004A36A1 /* GYStoresInfo+Private.h */,
372380
81C9AF542805BA8A004A36A1 /* GYStoreInfo+Private.h */,
373381
8166503F28DB689200E5B985 /* GYAccountableSku+Private.h */,
382+
81E5B8972912CE9700D134E9 /* GYAttributionItem+Private.h */,
374383
);
375384
name = Core;
376385
sourceTree = "<group>";
@@ -417,6 +426,7 @@
417426
isa = PBXHeadersBuildPhase;
418427
buildActionMask = 2147483647;
419428
files = (
429+
81E5B8962912C88400D134E9 /* GYAttributionItem.h in Headers */,
420430
81C9AF5F2805BB82004A36A1 /* GYStoresInfo.h in Headers */,
421431
811DB39F280975C900021880 /* GYSkuBase.h in Headers */,
422432
811BCDDF2608DA90007742D9 /* GYSysInfo.h in Headers */,
@@ -427,6 +437,7 @@
427437
81010F292590C1AB00B07DE4 /* GYAPIOfferingsResponse.h in Headers */,
428438
81951CD726443F94003901F1 /* GYOfferings.h in Headers */,
429439
8138BAB225924D0A005CB44E /* SKProductSubscriptionPeriod+GYEncode.h in Headers */,
440+
81E5B89A2912CEBC00D134E9 /* GYAttributionItem+Private.h in Headers */,
430441
81D18D7D2812AFE100C68558 /* GYSkuPaddle+Private.h in Headers */,
431442
81FCCE8627C3CE0A00DF3D1A /* GYPurchaseDelegate.h in Headers */,
432443
817A1CF5258CF63600D1BA10 /* GYAPIManager.h in Headers */,
@@ -591,6 +602,7 @@
591602
811DB39D280972C900021880 /* GYSkuBase.m in Sources */,
592603
8179459126565E32000EAA47 /* GYUtils.m in Sources */,
593604
81C9AF5C2805BB5B004A36A1 /* GYStoresInfo.m in Sources */,
605+
81E5B8942912C87600D134E9 /* GYAttributionItem.m in Sources */,
594606
81C9AF582805BAB1004A36A1 /* GYStoreInfo.m in Sources */,
595607
81C684662602633500223D3E /* GYAPISignatureResponse.m in Sources */,
596608
817A1C3E258CC9EA00D1BA10 /* GYOffering.m in Sources */,
@@ -777,7 +789,7 @@
777789
"@executable_path/Frameworks",
778790
"@loader_path/Frameworks",
779791
);
780-
MARKETING_VERSION = 1.3.4;
792+
MARKETING_VERSION = 1.3.5-beta.0;
781793
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
782794
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
783795
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -805,7 +817,7 @@
805817
"@executable_path/Frameworks",
806818
"@loader_path/Frameworks",
807819
);
808-
MARKETING_VERSION = 1.3.4;
820+
MARKETING_VERSION = 1.3.5-beta.0;
809821
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
810822
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
811823
PROVISIONING_PROFILE_SPECIFIER = "";

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Our SDK can be easly integrated through Cocoapods or Swift Package Manager
2020
#### Integrate using Cocoapods
2121
Add the pod to your Podfile:
2222

23-
```pod 'Glassfy', '~> 1.3.4'```
23+
```pod 'Glassfy', '~> 1.3.5-beta.0'```
2424

2525
Then, run the following command:
2626

Source/GYAPIManager.h

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
@class SKProduct;
2020
@class SKPaymentTransaction;
2121
@class GYCacheManager;
22+
@class GYAttributionItem;
2223

2324
typedef void(^GYGetInitCompletion)(GYAPIInitResponse* _Nullable, NSError* _Nullable);
2425
typedef void(^GYGetPermissionsCompletion)(GYAPIPermissionsResponse* _Nullable, NSError* _Nullable);
@@ -35,6 +36,7 @@ typedef GYBaseCompletion GYLogoutCompletion;
3536
typedef GYBaseCompletion GYLoginCompletion;
3637
typedef GYBaseCompletion GYPropertyCompletion;
3738
typedef GYBaseCompletion GYGetConnectCompletion;
39+
typedef GYBaseCompletion GYPostAttributionsCompletion;
3840

3941

4042
NS_ASSUME_NONNULL_BEGIN
@@ -75,6 +77,9 @@ NS_ASSUME_NONNULL_BEGIN
7577
- (void)getPaywall:(NSString *)paywallId locale:(NSString *_Nullable)locale completion:(GYGetPaywallCompletion _Nullable)block;
7678

7779
- (void)putLastSeen;
80+
81+
- (void)postAttributions:(NSArray<GYAttributionItem*> *)items withCompletion:(GYPostAttributionsCompletion _Nullable)block;
82+
7883
@end
7984

8085
NS_ASSUME_NONNULL_END

Source/GYAPIManager.m

+36
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "GYSku+Private.h"
1212
#import "SKPaymentTransaction+GYEncode.h"
1313
#import "SKProduct+GYEncode.h"
14+
#import "GYAttributionItem+Private.h"
1415
#import "GYSysInfo.h"
1516
#import "GYAPIManager.h"
1617
#import "GYError.h"
@@ -449,6 +450,41 @@ - (void)getPaywall:(NSString *)paywallId locale:(NSString *)locale completion:(G
449450
[self callApiWithRequest:req response:GYAPIPaywallResponse.class completion:block];
450451
}
451452

453+
- (void)postAttributions:(NSArray<GYAttributionItem*> *)items withCompletion:(GYPostAttributionsCompletion _Nullable)block
454+
{
455+
NSURLComponents *url = [self baseURLV0];
456+
url.path = [url.path stringByAppendingPathComponent:@"attribution"];
457+
458+
NSMutableDictionary *bodyEncoded = [NSMutableDictionary new];
459+
for (GYAttributionItem *item in items) {
460+
[bodyEncoded addEntriesFromDictionary:[item encodedObject]];
461+
}
462+
463+
NSError *err;
464+
NSData *body;
465+
if (![NSJSONSerialization isValidJSONObject:bodyEncoded]) {
466+
err = GYError.encodeData;
467+
}
468+
else {
469+
body = [NSJSONSerialization dataWithJSONObject:bodyEncoded options:kNilOptions error:&err];
470+
}
471+
if (err) {
472+
dispatch_async(Glassfy.shared.glqueue, ^{
473+
GYGetConnectCompletion completion = block;
474+
if (completion) {
475+
completion(nil, err);
476+
}
477+
});
478+
return;
479+
}
480+
481+
NSMutableURLRequest *req = [self authorizedRequestWithComponents:url];
482+
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
483+
[req setHTTPMethod:@"POST"];
484+
[req setHTTPBody:body];
485+
[self callApiWithRequest:req response:GYAPIBaseResponse.class completion:block];
486+
}
487+
452488
#pragma mark - private
453489

454490
- (NSMutableURLRequest *_Nullable)authorizedRequestWithComponents:(NSURLComponents *)urlComponents

Source/GYAttributionItem+Private.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// GYAttributionItem+Private.h
3+
// Glassfy
4+
//
5+
// Created by Luca Garbolino on 02/11/22.
6+
//
7+
8+
#import "GYAttributionItem.h"
9+
#import "GYCodableProtocol.h"
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface GYAttributionItem (Private) <GYEncodeProtocol>
14+
@end
15+
16+
NS_ASSUME_NONNULL_END
17+

Source/GYAttributionItem.m

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// GYAttributionItem.h
3+
// Glassfy
4+
//
5+
// Created by Luca Garbolino on 02/11/22.
6+
//
7+
8+
#import "GYAttributionItem+Private.h"
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface GYAttributionItem()
13+
@property(nonatomic, strong, nullable) NSString *value;
14+
@property(nonatomic, assign) GYAttributionType type;
15+
@end
16+
17+
@implementation GYAttributionItem (Private)
18+
19+
- (id)encodedObject
20+
{
21+
NSMutableDictionary *attributionInfo = [NSMutableDictionary dictionary];
22+
NSString *nameStr = [self.class attributionTypeToString:self.type];
23+
attributionInfo[nameStr] = self.value ?: [NSNull null];
24+
25+
return [NSDictionary dictionaryWithDictionary:attributionInfo];
26+
}
27+
28+
+ (NSString *)attributionTypeToString:(GYAttributionType)type {
29+
switch (type) {
30+
case GYAttributionTypeAdjustID: return @"adjustid";
31+
case GYAttributionTypeAppsFlyerID: return @"appsflyerid";
32+
case GYAttributionTypeIDFA: return @"idfa";
33+
case GYAttributionTypeIDFV: return @"idfv";
34+
case GYAttributionTypeIP: return @"ip";
35+
}
36+
}
37+
38+
@end
39+
40+
@implementation GYAttributionItem
41+
42+
+ (instancetype)attributionItemWithType:(GYAttributionType)type value:(NSString *_Nullable)value
43+
{
44+
GYAttributionItem *item = [GYAttributionItem new];
45+
item.type = type;
46+
item.value = value;
47+
48+
return item;
49+
}
50+
51+
@end
52+
53+
NS_ASSUME_NONNULL_END

Source/GYManager.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import "GYTypes.h"
1010
#import "GYPurchaseDelegate.h"
1111
@class GYSku;
12-
12+
@class GYAttributionItem;
1313

1414
NS_ASSUME_NONNULL_BEGIN
1515

@@ -36,7 +36,6 @@ NS_ASSUME_NONNULL_BEGIN
3636
- (void)setEmailUserProperty:(NSString *)email completion:(GYErrorCompletion)block;
3737
- (void)setDeviceToken:(NSString *)deviceToken completion:(GYErrorCompletion)block;
3838
- (void)setExtraUserProperty:(NSDictionary<NSString*,NSString*> *)extra completion:(GYErrorCompletion)block;
39-
4039
- (void)getUserProperties:(GYUserPropertiesCompletion)block;
4140

4241
- (void)connectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block;
@@ -48,6 +47,9 @@ NS_ASSUME_NONNULL_BEGIN
4847

4948
- (void)storeInfo:(GYStoreCompletion)block;
5049

50+
- (void)setAttributionWithType:(GYAttributionType)type value:(NSString *_Nullable)value completion:(GYErrorCompletion)block;
51+
- (void)setAttributions:(NSArray<GYAttributionItem*> *)attributions completion:(GYErrorCompletion)block;
52+
5153
@end
5254

5355
NS_ASSUME_NONNULL_END

Source/GYManager.m

+37
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,17 @@ - (void)storeInfo:(GYStoreCompletion)block
413413
}];
414414
}
415415

416+
- (void)setAttributionWithType:(GYAttributionType)type value:(NSString *_Nullable)value completion:(GYErrorCompletion)block
417+
{
418+
GYAttributionItem *item = [GYAttributionItem attributionItemWithType:type value:value];
419+
[self setAttributions:@[item] completion:block];
420+
}
421+
422+
- (void)setAttributions:(NSArray<GYAttributionItem *>*)attributions completion:(GYErrorCompletion)block
423+
{
424+
[self setAttributions:attributions maxRetries:10 completion:block];
425+
}
426+
416427

417428
#pragma mark - Notification
418429

@@ -818,5 +829,31 @@ - (void)setUserProperty:(GYUserPropertyType)property value:(id)obj completion:(G
818829
}];
819830
}
820831

832+
- (void)setAttributions:(NSArray<GYAttributionItem *>*)attributions maxRetries:(NSUInteger)times completion:(GYErrorCompletion)block
833+
{
834+
typeof(self) __weak weakSelf = self;
835+
GYPostAttributionsCompletion apiCompletion = ^(GYAPIBaseResponse *res, NSError *err) {
836+
if (err && times > 0) {
837+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8f * NSEC_PER_SEC)), Glassfy.shared.glqueue, ^{
838+
[weakSelf setAttributions:attributions maxRetries:(times-1) completion:block];
839+
});
840+
}
841+
else {
842+
typeof(block) __strong completion = block;
843+
if (completion) {
844+
dispatch_async(dispatch_get_main_queue(), ^{
845+
completion(err);
846+
});
847+
}
848+
}
849+
};
850+
851+
if (!self.initialized) {
852+
apiCompletion(nil, GYError.sdkNotInitialized);
853+
return;
854+
}
855+
856+
[self.api postAttributions:attributions withCompletion:apiCompletion];
857+
}
821858

822859
@end

Source/GYPaywallViewController+Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// GYPaywallViewController.h
2+
// GYPaywallViewController+Private.h
33
// Glassfy
44
//
55
// Created by Luca Garbolino on 13/10/21.

Source/GYStoreInfo+Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// GYStoreInfo+Private.h.h
2+
// GYStoreInfo+Private.h
33
// Glassfy
44
//
55
// Created by Luca Garbolino on 12/04/22.

Source/GYStoresInfo+Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// GYStoreInfo+Private.h.h
2+
// GYStoreInfo+Private.h
33
// Glassfy
44
//
55
// Created by Luca Garbolino on 12/04/22.

Source/GYUserProperties.m

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ @interface GYUserProperties()
1616
@implementation GYUserProperties (Private)
1717

1818
- (instancetype)initWithObject:(nonnull NSDictionary *)obj error:(NSError **)error {
19+
1920
self = [super init];
2021
if (self) {
2122
NSString *email = obj[GYUserPropertyTypeEmail];

Source/Glassfy.m

+14-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ + (Glassfy *)shared
4040

4141
+ (NSString *)sdkVersion
4242
{
43-
return @"1.3.4";
43+
return @"1.3.5-beta.0";
4444
}
4545

4646
+ (void)initializeWithAPIKey:(NSString *)apiKey
@@ -200,6 +200,19 @@ + (void)storeInfo:(GYStoreCompletion)block
200200
});
201201
}
202202

203+
+ (void)setAttributionWithType:(GYAttributionType)type value:(NSString *)value completion:(GYErrorCompletion)block
204+
{
205+
dispatch_async(Glassfy.shared.glqueue, ^{
206+
[Glassfy.shared.manager setAttributionWithType:type value:value completion:block];
207+
});
208+
}
209+
210+
+ (void)setAttributions:(NSArray<GYAttributionItem*> *)attributions completion:(GYErrorCompletion)block
211+
{
212+
dispatch_async(Glassfy.shared.glqueue, ^{
213+
[Glassfy.shared.manager setAttributions:attributions completion:block];
214+
});
215+
}
203216

204217
#pragma mark - Deprecations
205218

0 commit comments

Comments
 (0)