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

Commit

Permalink
Release v1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarbo committed Nov 28, 2022
1 parent 8efdf6c commit cdbbc31
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Glassfy.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Glassfy"
s.version = "1.3.4"
s.version = "1.3.5"
s.summary = "Subscription and in-app-purchase service."
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.source = { :git => "https://github.com/glassfy/ios-sdk.git", :tag => s.version.to_s }
Expand Down
16 changes: 14 additions & 2 deletions Glassfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
81D8D49A258B7193006BFE51 /* Glassfy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168309F258B6D9C00565968 /* Glassfy.framework */; };
81E1DC3225933FC7003B5EBD /* SKPayment+GYEncode.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E1DC3025933FC7003B5EBD /* SKPayment+GYEncode.h */; settings = {ATTRIBUTES = (Private, ); }; };
81E1DC3325933FC7003B5EBD /* SKPayment+GYEncode.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E1DC3125933FC7003B5EBD /* SKPayment+GYEncode.m */; };
81E5B8942912C87600D134E9 /* GYAttributionItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E5B8932912C87600D134E9 /* GYAttributionItem.m */; };
81E5B8962912C88400D134E9 /* GYAttributionItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E5B8952912C88400D134E9 /* GYAttributionItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
81E5B89A2912CEBC00D134E9 /* GYAttributionItem+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 81E5B8972912CE9700D134E9 /* GYAttributionItem+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
81EFB54425A772D900706FCB /* GYAPIPermissionsResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 81EFB54225A772D900706FCB /* GYAPIPermissionsResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
81EFB54525A772D900706FCB /* GYAPIPermissionsResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 81EFB54325A772D900706FCB /* GYAPIPermissionsResponse.m */; };
81EFB54B25A772F200706FCB /* GYPermission.m in Sources */ = {isa = PBXBuildFile; fileRef = 81EFB54925A772F200706FCB /* GYPermission.m */; };
Expand Down Expand Up @@ -213,6 +216,9 @@
81D8D499258B7193006BFE51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
81E1DC3025933FC7003B5EBD /* SKPayment+GYEncode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SKPayment+GYEncode.h"; sourceTree = "<group>"; };
81E1DC3125933FC7003B5EBD /* SKPayment+GYEncode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SKPayment+GYEncode.m"; sourceTree = "<group>"; };
81E5B8932912C87600D134E9 /* GYAttributionItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYAttributionItem.m; sourceTree = "<group>"; };
81E5B8952912C88400D134E9 /* GYAttributionItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYAttributionItem.h; path = Public/GYAttributionItem.h; sourceTree = "<group>"; };
81E5B8972912CE9700D134E9 /* GYAttributionItem+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GYAttributionItem+Private.h"; sourceTree = "<group>"; };
81EFB54225A772D900706FCB /* GYAPIPermissionsResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYAPIPermissionsResponse.h; sourceTree = "<group>"; };
81EFB54325A772D900706FCB /* GYAPIPermissionsResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYAPIPermissionsResponse.m; sourceTree = "<group>"; };
81EFB54925A772F200706FCB /* GYPermission.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYPermission.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -308,6 +314,8 @@
children = (
81951CD026443F65003901F1 /* Glassfy.h */,
817A1C75258CE0A200D1BA10 /* Glassfy.m */,
81E5B8952912C88400D134E9 /* GYAttributionItem.h */,
81E5B8932912C87600D134E9 /* GYAttributionItem.m */,
81951CD526443F94003901F1 /* GYOfferings.h */,
810F6FB225E50CFF00D3009E /* GYOfferings.m */,
81951CD426443F94003901F1 /* GYOffering.h */,
Expand Down Expand Up @@ -371,6 +379,7 @@
81C9AF672805D2F3004A36A1 /* GYStoresInfo+Private.h */,
81C9AF542805BA8A004A36A1 /* GYStoreInfo+Private.h */,
8166503F28DB689200E5B985 /* GYAccountableSku+Private.h */,
81E5B8972912CE9700D134E9 /* GYAttributionItem+Private.h */,
);
name = Core;
sourceTree = "<group>";
Expand Down Expand Up @@ -417,6 +426,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
81E5B8962912C88400D134E9 /* GYAttributionItem.h in Headers */,
81C9AF5F2805BB82004A36A1 /* GYStoresInfo.h in Headers */,
811DB39F280975C900021880 /* GYSkuBase.h in Headers */,
811BCDDF2608DA90007742D9 /* GYSysInfo.h in Headers */,
Expand All @@ -427,6 +437,7 @@
81010F292590C1AB00B07DE4 /* GYAPIOfferingsResponse.h in Headers */,
81951CD726443F94003901F1 /* GYOfferings.h in Headers */,
8138BAB225924D0A005CB44E /* SKProductSubscriptionPeriod+GYEncode.h in Headers */,
81E5B89A2912CEBC00D134E9 /* GYAttributionItem+Private.h in Headers */,
81D18D7D2812AFE100C68558 /* GYSkuPaddle+Private.h in Headers */,
81FCCE8627C3CE0A00DF3D1A /* GYPurchaseDelegate.h in Headers */,
817A1CF5258CF63600D1BA10 /* GYAPIManager.h in Headers */,
Expand Down Expand Up @@ -591,6 +602,7 @@
811DB39D280972C900021880 /* GYSkuBase.m in Sources */,
8179459126565E32000EAA47 /* GYUtils.m in Sources */,
81C9AF5C2805BB5B004A36A1 /* GYStoresInfo.m in Sources */,
81E5B8942912C87600D134E9 /* GYAttributionItem.m in Sources */,
81C9AF582805BAB1004A36A1 /* GYStoreInfo.m in Sources */,
81C684662602633500223D3E /* GYAPISignatureResponse.m in Sources */,
817A1C3E258CC9EA00D1BA10 /* GYOffering.m in Sources */,
Expand Down Expand Up @@ -777,7 +789,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.4;
MARKETING_VERSION = 1.3.5;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -805,7 +817,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.4;
MARKETING_VERSION = 1.3.5;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Our SDK can be easly integrated through Cocoapods or Swift Package Manager
#### Integrate using Cocoapods
Add the pod to your Podfile:

```pod 'Glassfy', '~> 1.3.4'```
```pod 'Glassfy', '~> 1.3.5'```

Then, run the following command:

Expand Down
5 changes: 5 additions & 0 deletions Source/GYAPIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@class SKProduct;
@class SKPaymentTransaction;
@class GYCacheManager;
@class GYAttributionItem;

typedef void(^GYGetInitCompletion)(GYAPIInitResponse* _Nullable, NSError* _Nullable);
typedef void(^GYGetPermissionsCompletion)(GYAPIPermissionsResponse* _Nullable, NSError* _Nullable);
Expand All @@ -35,6 +36,7 @@ typedef GYBaseCompletion GYLogoutCompletion;
typedef GYBaseCompletion GYLoginCompletion;
typedef GYBaseCompletion GYPropertyCompletion;
typedef GYBaseCompletion GYGetConnectCompletion;
typedef GYBaseCompletion GYPostAttributionsCompletion;


NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -75,6 +77,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getPaywall:(NSString *)paywallId locale:(NSString *_Nullable)locale completion:(GYGetPaywallCompletion _Nullable)block;

- (void)putLastSeen;

- (void)postAttributions:(NSArray<GYAttributionItem*> *)items withCompletion:(GYPostAttributionsCompletion _Nullable)block;

@end

NS_ASSUME_NONNULL_END
36 changes: 36 additions & 0 deletions Source/GYAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "GYSku+Private.h"
#import "SKPaymentTransaction+GYEncode.h"
#import "SKProduct+GYEncode.h"
#import "GYAttributionItem+Private.h"
#import "GYSysInfo.h"
#import "GYAPIManager.h"
#import "GYError.h"
Expand Down Expand Up @@ -449,6 +450,41 @@ - (void)getPaywall:(NSString *)paywallId locale:(NSString *)locale completion:(G
[self callApiWithRequest:req response:GYAPIPaywallResponse.class completion:block];
}

- (void)postAttributions:(NSArray<GYAttributionItem*> *)items withCompletion:(GYPostAttributionsCompletion _Nullable)block
{
NSURLComponents *url = [self baseURLV0];
url.path = [url.path stringByAppendingPathComponent:@"attribution"];

NSMutableDictionary *bodyEncoded = [NSMutableDictionary new];
for (GYAttributionItem *item in items) {
[bodyEncoded addEntriesFromDictionary:[item encodedObject]];
}

NSError *err;
NSData *body;
if (![NSJSONSerialization isValidJSONObject:bodyEncoded]) {
err = GYError.encodeData;
}
else {
body = [NSJSONSerialization dataWithJSONObject:bodyEncoded options:kNilOptions error:&err];
}
if (err) {
dispatch_async(Glassfy.shared.glqueue, ^{
GYGetConnectCompletion completion = block;
if (completion) {
completion(nil, err);
}
});
return;
}

NSMutableURLRequest *req = [self authorizedRequestWithComponents:url];
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:body];
[self callApiWithRequest:req response:GYAPIBaseResponse.class completion:block];
}

#pragma mark - private

- (NSMutableURLRequest *_Nullable)authorizedRequestWithComponents:(NSURLComponents *)urlComponents
Expand Down
17 changes: 17 additions & 0 deletions Source/GYAttributionItem+Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// GYAttributionItem+Private.h
// Glassfy
//
// Created by Luca Garbolino on 02/11/22.
//

#import "GYAttributionItem.h"
#import "GYCodableProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface GYAttributionItem (Private) <GYEncodeProtocol>
@end

NS_ASSUME_NONNULL_END

53 changes: 53 additions & 0 deletions Source/GYAttributionItem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// GYAttributionItem.h
// Glassfy
//
// Created by Luca Garbolino on 02/11/22.
//

#import "GYAttributionItem+Private.h"

NS_ASSUME_NONNULL_BEGIN

@interface GYAttributionItem()
@property(nonatomic, strong, nullable) NSString *value;
@property(nonatomic, assign) GYAttributionType type;
@end

@implementation GYAttributionItem (Private)

- (id)encodedObject
{
NSMutableDictionary *attributionInfo = [NSMutableDictionary dictionary];
NSString *nameStr = [self.class attributionTypeToString:self.type];
attributionInfo[nameStr] = self.value ?: [NSNull null];

return [NSDictionary dictionaryWithDictionary:attributionInfo];
}

+ (NSString *)attributionTypeToString:(GYAttributionType)type {
switch (type) {
case GYAttributionTypeAdjustID: return @"adjustid";
case GYAttributionTypeAppsFlyerID: return @"appsflyerid";
case GYAttributionTypeIDFA: return @"idfa";
case GYAttributionTypeIDFV: return @"idfv";
case GYAttributionTypeIP: return @"ip";
}
}

@end

@implementation GYAttributionItem

+ (instancetype)attributionItemWithType:(GYAttributionType)type value:(NSString *_Nullable)value
{
GYAttributionItem *item = [GYAttributionItem new];
item.type = type;
item.value = value;

return item;
}

@end

NS_ASSUME_NONNULL_END
5 changes: 4 additions & 1 deletion Source/GYManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "GYTypes.h"
#import "GYPurchaseDelegate.h"
@class GYSku;

@class GYAttributionItem;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -48,6 +48,9 @@ NS_ASSUME_NONNULL_BEGIN

- (void)storeInfo:(GYStoreCompletion)block;

- (void)setAttributionWithType:(GYAttributionType)type value:(NSString *_Nullable)value completion:(GYErrorCompletion)block;
- (void)setAttributions:(NSArray<GYAttributionItem*> *)attributions completion:(GYErrorCompletion)block;

@end

NS_ASSUME_NONNULL_END
37 changes: 37 additions & 0 deletions Source/GYManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@ - (void)storeInfo:(GYStoreCompletion)block
}];
}

- (void)setAttributionWithType:(GYAttributionType)type value:(NSString *_Nullable)value completion:(GYErrorCompletion)block
{
GYAttributionItem *item = [GYAttributionItem attributionItemWithType:type value:value];
[self setAttributions:@[item] completion:block];
}

- (void)setAttributions:(NSArray<GYAttributionItem *>*)attributions completion:(GYErrorCompletion)block
{
[self setAttributions:attributions maxRetries:10 completion:block];
}


#pragma mark - Notification

Expand Down Expand Up @@ -818,5 +829,31 @@ - (void)setUserProperty:(GYUserPropertyType)property value:(id)obj completion:(G
}];
}

- (void)setAttributions:(NSArray<GYAttributionItem *>*)attributions maxRetries:(NSUInteger)times completion:(GYErrorCompletion)block
{
typeof(self) __weak weakSelf = self;
GYPostAttributionsCompletion apiCompletion = ^(GYAPIBaseResponse *res, NSError *err) {
if (err && times > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8f * NSEC_PER_SEC)), Glassfy.shared.glqueue, ^{
[weakSelf setAttributions:attributions maxRetries:(times-1) completion:block];
});
}
else {
typeof(block) __strong completion = block;
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(err);
});
}
}
};

if (!self.initialized) {
apiCompletion(nil, GYError.sdkNotInitialized);
return;
}

[self.api postAttributions:attributions withCompletion:apiCompletion];
}

@end
2 changes: 1 addition & 1 deletion Source/GYPaywallViewController+Private.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// GYPaywallViewController.h
// GYPaywallViewController+Private.h
// Glassfy
//
// Created by Luca Garbolino on 13/10/21.
Expand Down
2 changes: 1 addition & 1 deletion Source/GYStoreInfo+Private.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// GYStoreInfo+Private.h.h
// GYStoreInfo+Private.h
// Glassfy
//
// Created by Luca Garbolino on 12/04/22.
Expand Down
2 changes: 1 addition & 1 deletion Source/GYStoresInfo+Private.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// GYStoreInfo+Private.h.h
// GYStoreInfo+Private.h
// Glassfy
//
// Created by Luca Garbolino on 12/04/22.
Expand Down
15 changes: 14 additions & 1 deletion Source/Glassfy.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (Glassfy *)shared

+ (NSString *)sdkVersion
{
return @"1.3.4";
return @"1.3.5";
}

+ (void)initializeWithAPIKey:(NSString *)apiKey
Expand Down Expand Up @@ -200,6 +200,19 @@ + (void)storeInfo:(GYStoreCompletion)block
});
}

+ (void)setAttributionWithType:(GYAttributionType)type value:(NSString *)value completion:(GYErrorCompletion)block
{
dispatch_async(Glassfy.shared.glqueue, ^{
[Glassfy.shared.manager setAttributionWithType:type value:value completion:block];
});
}

+ (void)setAttributions:(NSArray<GYAttributionItem*> *)attributions completion:(GYErrorCompletion)block
{
dispatch_async(Glassfy.shared.glqueue, ^{
[Glassfy.shared.manager setAttributions:attributions completion:block];
});
}

#pragma mark - Deprecations

Expand Down
24 changes: 24 additions & 0 deletions Source/Public/GYAttributionItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// GYAttributionItem.h
// Glassfy
//
// Created by Luca Garbolino on 02/11/22.
//

#import <Foundation/Foundation.h>
#if __has_include(<Glassfy/GYTypes.h>)
#import <Glassfy/GYTypes.h>
#else
#import "GYTypes.h"
#endif

NS_ASSUME_NONNULL_BEGIN

NS_SWIFT_NAME(Glassfy.AttributionItem)
@interface GYAttributionItem : NSObject

+ (instancetype)attributionItemWithType:(GYAttributionType)name value:(NSString *_Nullable)value;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit cdbbc31

Please sign in to comment.