From eae4e00de6bb9db1cf4586a926b2ae4bd0870817 Mon Sep 17 00:00:00 2001 From: Luca Garbolino <387293+lgarbo@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:56:48 +0100 Subject: [PATCH] Release v1.3.7 --- Glassfy.podspec | 2 +- Glassfy.xcodeproj/project.pbxproj | 12 +++++-- README.md | 2 +- Source/GYAPIManager.h | 4 ++- Source/GYAPIManager.m | 13 +++++++- Source/GYInitializeOptions.m | 52 +++++++++++++++++++++++++++++ Source/GYManager.h | 3 +- Source/GYManager.m | 20 ++++++----- Source/Glassfy.m | 12 +++++-- Source/Public/GYInitializeOptions.h | 32 ++++++++++++++++++ Source/Public/Glassfy.h | 9 +++++ 11 files changed, 144 insertions(+), 17 deletions(-) create mode 100644 Source/GYInitializeOptions.m create mode 100644 Source/Public/GYInitializeOptions.h diff --git a/Glassfy.podspec b/Glassfy.podspec index c107cd2..6831c08 100644 --- a/Glassfy.podspec +++ b/Glassfy.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Glassfy" - s.version = "1.3.6" + s.version = "1.3.7" 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 } diff --git a/Glassfy.xcodeproj/project.pbxproj b/Glassfy.xcodeproj/project.pbxproj index ac0740e..68e6e53 100644 --- a/Glassfy.xcodeproj/project.pbxproj +++ b/Glassfy.xcodeproj/project.pbxproj @@ -27,6 +27,8 @@ 811F31BC26317ED300777020 /* GYTransaction+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8161C49E2594DF87009CA563 /* GYTransaction+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 811F31C126317ED800777020 /* GYSku+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 81A7064425ACADB200169564 /* GYSku+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 811F322E2631CC6C00777020 /* Glassfy+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 811F322D2631CC6C00777020 /* Glassfy+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 812767FC29CC990200498889 /* GYInitializeOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 812767FA29CC990200498889 /* GYInitializeOptions.m */; }; + 812767FE29CCA7F800498889 /* GYInitializeOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 812767FD29CCA7F800498889 /* GYInitializeOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 812C842229B5F51F00A3F736 /* GYPurchasesHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = 812C842029B5F51F00A3F736 /* GYPurchasesHistory.m */; }; 812C842429B5F55200A3F736 /* GYPurchasesHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = 812C842329B5F55200A3F736 /* GYPurchasesHistory.h */; settings = {ATTRIBUTES = (Public, ); }; }; 812C842629B5F58800A3F736 /* GYPurchasesHistory+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 812C842529B5F58800A3F736 /* GYPurchasesHistory+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -142,6 +144,8 @@ 811DB39E280975C900021880 /* GYSkuBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYSkuBase.h; path = Public/GYSkuBase.h; sourceTree = ""; }; 811DB3A0280977C800021880 /* GYSkuBase+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GYSkuBase+Private.h"; sourceTree = ""; }; 811F322D2631CC6C00777020 /* Glassfy+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Glassfy+Private.h"; sourceTree = ""; }; + 812767FA29CC990200498889 /* GYInitializeOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYInitializeOptions.m; sourceTree = ""; }; + 812767FD29CCA7F800498889 /* GYInitializeOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYInitializeOptions.h; path = Public/GYInitializeOptions.h; sourceTree = ""; }; 812C842029B5F51F00A3F736 /* GYPurchasesHistory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYPurchasesHistory.m; sourceTree = ""; }; 812C842329B5F55200A3F736 /* GYPurchasesHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYPurchasesHistory.h; path = Public/GYPurchasesHistory.h; sourceTree = ""; }; 812C842529B5F58800A3F736 /* GYPurchasesHistory+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GYPurchasesHistory+Private.h"; sourceTree = ""; }; @@ -360,6 +364,8 @@ 812C842C29B5FD9200A3F736 /* GYPurchaseHistory.m */, 812C842329B5F55200A3F736 /* GYPurchasesHistory.h */, 812C842029B5F51F00A3F736 /* GYPurchasesHistory.m */, + 812767FD29CCA7F800498889 /* GYInitializeOptions.h */, + 812767FA29CC990200498889 /* GYInitializeOptions.m */, 81C9AF5D2805BB82004A36A1 /* GYStoresInfo.h */, 81C9AF5A2805BB5B004A36A1 /* GYStoresInfo.m */, 81C9AF5E2805BB82004A36A1 /* GYStoreInfo.h */, @@ -459,6 +465,7 @@ 817A1CFF258CF7EE00D1BA10 /* GYStoreRequest.h in Headers */, 817A1CB7258CE81000D1BA10 /* GYLogger.h in Headers */, 81010F292590C1AB00B07DE4 /* GYAPIOfferingsResponse.h in Headers */, + 812767FE29CCA7F800498889 /* GYInitializeOptions.h in Headers */, 81951CD726443F94003901F1 /* GYOfferings.h in Headers */, 8138BAB225924D0A005CB44E /* SKProductSubscriptionPeriod+GYEncode.h in Headers */, 81E5B89A2912CEBC00D134E9 /* GYAttributionItem+Private.h in Headers */, @@ -651,6 +658,7 @@ 8138BAA925924CDF005CB44E /* SKPaymentDiscount+GYEncode.m in Sources */, 816EF28A2661161200513FB1 /* GYUserProperties.m in Sources */, 8138BAB325924D0A005CB44E /* SKProductSubscriptionPeriod+GYEncode.m in Sources */, + 812767FC29CC990200498889 /* GYInitializeOptions.m in Sources */, 817A1C76258CE0A200D1BA10 /* Glassfy.m in Sources */, 81B49B562729A31C000BDDA1 /* GYFormatter.m in Sources */, 816EF28E26611C5900513FB1 /* GYAPIPropertiesResponse.m in Sources */, @@ -821,7 +829,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.3.6; + MARKETING_VERSION = 1.3.7; PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -849,7 +857,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.3.6; + MARKETING_VERSION = 1.3.7; PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/README.md b/README.md index 32450a3..0ea3e81 100644 --- a/README.md +++ b/README.md @@ -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.6'``` +```pod 'Glassfy', '~> 1.3.7'``` Then, run the following command: diff --git a/Source/GYAPIManager.h b/Source/GYAPIManager.h index e0e78ef..617761d 100644 --- a/Source/GYAPIManager.h +++ b/Source/GYAPIManager.h @@ -48,7 +48,9 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithApiKey:(NSString *)apiKey cache:(GYCacheManager *)cache; -- (void)getInitWithInfoWithCompletion:(GYGetInitCompletion _Nullable)block; +- (void)getInitWithCrossPlatformSdkFramework:(NSString *_Nullable)framework + crossPlatformSdkVersion:(NSString *_Nullable)version + completion:(GYGetInitCompletion _Nullable)block; - (void)getSkuWithId:(NSString *)skuid store:(GYStore)store withCompletion:(GYGetSkuCompletion _Nullable)block; - (void)getSkuWithProductId:(NSString *)productid promotionalId:(NSString *_Nullable)promoid withCompletion:(GYGetSkuCompletion _Nullable)block; diff --git a/Source/GYAPIManager.m b/Source/GYAPIManager.m index a5e3ecc..5b35569 100644 --- a/Source/GYAPIManager.m +++ b/Source/GYAPIManager.m @@ -85,11 +85,22 @@ - (NSURLComponents *)baseURLV1 #pragma mark - public -- (void)getInitWithInfoWithCompletion:(GYGetInitCompletion)block +- (void)getInitWithCrossPlatformSdkFramework:(NSString *)framework + crossPlatformSdkVersion:(NSString *)version + completion:(GYGetInitCompletion)block { NSURLComponents *url = [self baseURLV0]; url.path = [url.path stringByAppendingPathComponent:@"init"]; + NSMutableArray *queryItems = [(url.queryItems ?: @[]) mutableCopy]; + if (framework) { + [queryItems addObject:[NSURLQueryItem queryItemWithName:@"cross_platform_sdk_framework" value:framework]]; + } + if (version) { + [queryItems addObject:[NSURLQueryItem queryItemWithName:@"cross_platform_sdk_version" value:version]]; + } + url.queryItems = queryItems; + NSURLRequest *req = [self authorizedRequestWithComponents:url]; [self callApiWithRequest:req response:GYAPIInitResponse.class completion:block]; } diff --git a/Source/GYInitializeOptions.m b/Source/GYInitializeOptions.m new file mode 100644 index 0000000..5bb6faa --- /dev/null +++ b/Source/GYInitializeOptions.m @@ -0,0 +1,52 @@ +// +// GYInitializeOptions.m +// Glassfy +// +// Created by Luca Garbolino on 23/03/23. +// + +#import "GYInitializeOptions.h" + +@interface GYInitializeOptions() +@property(nonatomic, readwrite, strong) NSString *apiKey; +@end + +@implementation GYInitializeOptions + + ++ (instancetype)initializeOptionsWithAPIKey:(NSString *)apiKey +{ + return [[self alloc] initWithAPIKey:apiKey]; +} + +- (GYInitializeOptions *)watcherMode:(BOOL)enable +{ + self.watcherMode = enable; + return self; +} + +- (GYInitializeOptions *)crossPlatformSdkFramework:(NSString *)framework +{ + self.crossPlatformSdkFramework = framework; + return self; +} + +- (GYInitializeOptions *)crossPlatformSdkVersion:(NSString *)version +{ + self.crossPlatformSdkVersion = version; + return self; +} + + +#pragma mark - private + +- (instancetype)initWithAPIKey:(NSString *)apiKey +{ + self = [super init]; + if (self) { + _apiKey = apiKey; + } + return self; +} + +@end diff --git a/Source/GYManager.h b/Source/GYManager.h index 9d5b358..4b13b74 100644 --- a/Source/GYManager.h +++ b/Source/GYManager.h @@ -10,6 +10,7 @@ #import "GYPurchaseDelegate.h" @class GYSku; @class GYAttributionItem; +@class GYInitializeOptions; NS_ASSUME_NONNULL_BEGIN @@ -17,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly, strong, nonnull) NSString *apiKey; @property(nonatomic, readonly, assign) BOOL watcherMode; -+ (GYManager *)managerWithApiKey:(NSString *)apiKey watcherMode:(BOOL)watcherMode; ++ (GYManager *)managerWithOptions:(GYInitializeOptions *)options; - (void)setPurchaseDelegate:(id)delegate; diff --git a/Source/GYManager.m b/Source/GYManager.m index 43aa7ad..8516235 100644 --- a/Source/GYManager.m +++ b/Source/GYManager.m @@ -27,12 +27,13 @@ #import "Glassfy+Private.h" #import "GYPurchasesHistory+Private.h" #import "GYSysInfo.h" +#import "GYInitializeOptions.h" @interface GYManager() @property(nonatomic, strong) GYCacheManager *cache; @property(nonatomic, strong) GYAPIManager *api; @property(nonatomic, strong) GYStoreRequest *store; -@property(nonatomic, assign) BOOL watcherMode; +@property(nonatomic, strong) GYInitializeOptions *options; @property(nonatomic, assign) BOOL initialized; @property(nonatomic, weak) id purchasesDelegate; @@ -41,21 +42,22 @@ @interface GYManager() @implementation GYManager -+ (GYManager *)managerWithApiKey:(NSString *)apiKey watcherMode:(BOOL)watcherMode ++ (GYManager *)managerWithOptions:(GYInitializeOptions *)options { - GYManager *manager = [[self alloc] initWithApiKey:apiKey watcherMode:watcherMode]; + GYManager *manager = [[self alloc] initWithInitializeOptions:options]; [manager startSDK]; return manager; } -- (instancetype)initWithApiKey:(NSString *)apiKey watcherMode:(BOOL)watcherMode +- (instancetype)initWithInitializeOptions:(GYInitializeOptions *)options { self = [super init]; if (self) { - self.watcherMode = watcherMode; + self.options = options; + self.store = [GYStoreRequest new]; self.cache = [GYCacheManager new]; - self.api = [[GYAPIManager alloc] initWithApiKey:apiKey cache:self.cache]; + self.api = [[GYAPIManager alloc] initWithApiKey:options.apiKey cache:self.cache]; self.purchaseCompletions = [NSMapTable mapTableWithKeyOptions:NSMapTableStrongMemory valueOptions:NSMapTableCopyIn]; if (GYSysInfo.applicationDidBecomeActiveNotification) { @@ -114,7 +116,7 @@ - (void)logoutWithCompletion:(GYErrorCompletion _Nullable)block - (BOOL)watcherMode { - return _watcherMode; + return self.options.watcherMode; } - (void)permissionsWithCompletion:(GYPermissionsCompletion)block @@ -714,7 +716,9 @@ - (void)startSDK } }; - [self.api getInitWithInfoWithCompletion:^(GYAPIInitResponse *res, NSError *err) { + [self.api getInitWithCrossPlatformSdkFramework:self.options.crossPlatformSdkFramework + crossPlatformSdkVersion:self.options.crossPlatformSdkVersion + completion:^(GYAPIInitResponse *res, NSError *err) { BOOL shouldSendReceipt = !res.hasReceipt; [self.store productWithSkus:res.skus completion:^(NSArray *products, NSError *err) { if (products.count) { diff --git a/Source/Glassfy.m b/Source/Glassfy.m index 407a3b1..d66893f 100644 --- a/Source/Glassfy.m +++ b/Source/Glassfy.m @@ -40,7 +40,7 @@ + (Glassfy *)shared + (NSString *)sdkVersion { - return @"1.3.6"; + return @"1.3.7"; } + (void)initializeWithAPIKey:(NSString *)apiKey @@ -49,9 +49,17 @@ + (void)initializeWithAPIKey:(NSString *)apiKey } + (void)initializeWithAPIKey:(NSString *)apiKey watcherMode:(BOOL)watcherMode +{ + GYInitializeOptions *opt = [GYInitializeOptions initializeOptionsWithAPIKey:apiKey]; + opt.watcherMode = watcherMode; + + [self initializeWithOptions:opt]; +} + ++ (void)initializeWithOptions:(GYInitializeOptions *)options { dispatch_async(Glassfy.shared.glqueue, ^{ - Glassfy.shared.manager = [GYManager managerWithApiKey:apiKey watcherMode:watcherMode]; + Glassfy.shared.manager = [GYManager managerWithOptions:options]; }); } diff --git a/Source/Public/GYInitializeOptions.h b/Source/Public/GYInitializeOptions.h new file mode 100644 index 0000000..4bea9da --- /dev/null +++ b/Source/Public/GYInitializeOptions.h @@ -0,0 +1,32 @@ +// +// GYInitializeOptions.h +// Glassfy +// +// Created by Luca Garbolino on 23/03/23. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +NS_SWIFT_NAME(Glassfy.InitializeOptions) +@interface GYInitializeOptions : NSObject + +@property(nonatomic, assign) BOOL watcherMode; +@property(nonatomic, readonly, strong) NSString *apiKey; +@property(nonatomic, strong, nullable) NSString *crossPlatformSdkFramework; +@property(nonatomic, strong, nullable) NSString *crossPlatformSdkVersion; + ++ (instancetype)initializeOptionsWithAPIKey:(NSString *)apiKey; + +- (GYInitializeOptions *)watcherMode:(BOOL)mode; + +- (GYInitializeOptions *)crossPlatformSdkFramework:(NSString *_Nullable)framework; +- (GYInitializeOptions *)crossPlatformSdkVersion:(NSString *_Nullable)version; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/Public/Glassfy.h b/Source/Public/Glassfy.h index cfe7d63..857a1a8 100644 --- a/Source/Public/Glassfy.h +++ b/Source/Public/Glassfy.h @@ -28,6 +28,7 @@ #import #import #import +#import #else #import "GYSku.h" #import "GYSkuPaddle.h" @@ -48,6 +49,7 @@ #import "GYStoresInfo.h" #import "GYStoreInfoPaddle.h" #import "GYAttributionItem.h" +#import "GYInitializeOptions.h" #endif @@ -85,6 +87,13 @@ NS_ASSUME_NONNULL_BEGIN */ + (void)initializeWithAPIKey:(NSString *)apiKey watcherMode:(BOOL)watcherMode NS_SWIFT_NAME(initialize(apiKey:watcherMode:)); +/** + Initialize the SDK + + @param options Initialization options + */ ++ (void)initializeWithOptions:(GYInitializeOptions *)options NS_SWIFT_NAME(initialize(options:)); + /** Chek permissions status of the user