From 17df47e4dd70725c68916e93ce59dca4ae626f8d Mon Sep 17 00:00:00 2001 From: lgarbo <387293+lgarbo@users.noreply.github.com> Date: Wed, 13 Apr 2022 14:42:22 +0200 Subject: [PATCH] Release v1.3.0-beta.1 --- Glassfy.podspec | 2 +- Glassfy.xcodeproj/project.pbxproj | 46 +++++++++++++++++++--- README.md | 2 +- Source/GYAPIManager.h | 10 +++-- Source/GYAPIManager.m | 19 ++++++--- Source/GYAPIPlatformInfoResponse.h | 18 +++++++++ Source/GYAPIPlatformInfoResponse.m | 38 ++++++++++++++++++ Source/GYManager.h | 4 +- Source/GYManager.m | 15 +++++++ Source/GYPlatform.h | 14 ------- Source/GYPlatformInfo+Private.h | 16 ++++++++ Source/GYPlatformInfo.m | 51 ++++++++++++++++++++++++ Source/GYPlatformInfoPaddle.m | 58 ++++++++++++++++++++++++++++ Source/GYPlatformsInfo+Private.h | 17 ++++++++ Source/GYPlatformsInfo.m | 34 ++++++++++++++++ Source/Glassfy.m | 12 ++++-- Source/Public/GYPlatformInfo.h | 23 +++++++++++ Source/Public/GYPlatformInfoPaddle.h | 28 ++++++++++++++ Source/Public/GYPlatformsInfo.h | 25 ++++++++++++ Source/Public/GYTypes.h | 8 ++++ Source/Public/Glassfy.h | 45 +++++++++++++-------- 21 files changed, 434 insertions(+), 51 deletions(-) create mode 100644 Source/GYAPIPlatformInfoResponse.h create mode 100644 Source/GYAPIPlatformInfoResponse.m delete mode 100644 Source/GYPlatform.h create mode 100644 Source/GYPlatformInfo+Private.h create mode 100644 Source/GYPlatformInfo.m create mode 100644 Source/GYPlatformInfoPaddle.m create mode 100644 Source/GYPlatformsInfo+Private.h create mode 100644 Source/GYPlatformsInfo.m create mode 100644 Source/Public/GYPlatformInfo.h create mode 100644 Source/Public/GYPlatformInfoPaddle.h create mode 100644 Source/Public/GYPlatformsInfo.h diff --git a/Glassfy.podspec b/Glassfy.podspec index f980315..acc3ef3 100644 --- a/Glassfy.podspec +++ b/Glassfy.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Glassfy" - s.version = "1.3.0-beta.0" + s.version = "1.3.0-beta.1" 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 90038d4..1c867f6 100644 --- a/Glassfy.xcodeproj/project.pbxproj +++ b/Glassfy.xcodeproj/project.pbxproj @@ -36,7 +36,6 @@ 8138BAB325924D0A005CB44E /* SKProductSubscriptionPeriod+GYEncode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8138BAB125924D0A005CB44E /* SKProductSubscriptionPeriod+GYEncode.m */; }; 8161C42825948D82009CA563 /* GYError.m in Sources */ = {isa = PBXBuildFile; fileRef = 8161C42625948D82009CA563 /* GYError.m */; }; 8161C4992594DD2F009CA563 /* GYTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 8161C4972594DD2F009CA563 /* GYTransaction.m */; }; - 8168224727F1DC5E002B9857 /* GYPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 8168224627F1DB5E002B9857 /* GYPlatform.h */; settings = {ATTRIBUTES = (Private, ); }; }; 816830B8258B6EE400565968 /* GYManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 816830B6258B6EE400565968 /* GYManager.h */; settings = {ATTRIBUTES = (Private, ); }; }; 816830B9258B6EE400565968 /* GYManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 816830B7258B6EE400565968 /* GYManager.m */; }; 816EF28A2661161200513FB1 /* GYUserProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 816EF2882661161200513FB1 /* GYUserProperties.m */; }; @@ -78,6 +77,15 @@ 81C2816325E3F58C0048189D /* GYPermissions.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C2816125E3F58C0048189D /* GYPermissions.m */; }; 81C684652602633500223D3E /* GYAPISignatureResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C684632602633500223D3E /* GYAPISignatureResponse.h */; settings = {ATTRIBUTES = (Private, ); }; }; 81C684662602633500223D3E /* GYAPISignatureResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C684642602633500223D3E /* GYAPISignatureResponse.m */; }; + 81C9AF522805B665004A36A1 /* GYAPIPlatformInfoResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C9AF502805B665004A36A1 /* GYAPIPlatformInfoResponse.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 81C9AF532805B665004A36A1 /* GYAPIPlatformInfoResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C9AF512805B665004A36A1 /* GYAPIPlatformInfoResponse.m */; }; + 81C9AF582805BAB1004A36A1 /* GYPlatformInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C9AF562805BAB1004A36A1 /* GYPlatformInfo.m */; }; + 81C9AF5C2805BB5B004A36A1 /* GYPlatformsInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C9AF5A2805BB5B004A36A1 /* GYPlatformsInfo.m */; }; + 81C9AF5F2805BB82004A36A1 /* GYPlatformsInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C9AF5D2805BB82004A36A1 /* GYPlatformsInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 81C9AF602805BB82004A36A1 /* GYPlatformInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C9AF5E2805BB82004A36A1 /* GYPlatformInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 81C9AF642805C36B004A36A1 /* GYPlatformInfoPaddle.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C9AF622805C36B004A36A1 /* GYPlatformInfoPaddle.m */; }; + 81C9AF662805C386004A36A1 /* GYPlatformInfoPaddle.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C9AF652805C386004A36A1 /* GYPlatformInfoPaddle.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 81C9AF682805D2F3004A36A1 /* GYPlatformsInfo+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C9AF672805D2F3004A36A1 /* GYPlatformsInfo+Private.h */; }; 81D8D498258B7193006BFE51 /* GlassfyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81D8D497258B7193006BFE51 /* GlassfyTests.swift */; }; 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, ); }; }; @@ -126,7 +134,6 @@ 8161C42625948D82009CA563 /* GYError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYError.m; sourceTree = ""; }; 8161C4972594DD2F009CA563 /* GYTransaction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYTransaction.m; sourceTree = ""; }; 8161C49E2594DF87009CA563 /* GYTransaction+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GYTransaction+Private.h"; sourceTree = ""; }; - 8168224627F1DB5E002B9857 /* GYPlatform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYPlatform.h; sourceTree = ""; }; 8168309F258B6D9C00565968 /* Glassfy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Glassfy.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 816830A3258B6D9C00565968 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 816830B6258B6EE400565968 /* GYManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYManager.h; sourceTree = ""; }; @@ -172,6 +179,16 @@ 81C2816825E3F6AC0048189D /* GYPermissions+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GYPermissions+Private.h"; sourceTree = ""; }; 81C684632602633500223D3E /* GYAPISignatureResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYAPISignatureResponse.h; sourceTree = ""; }; 81C684642602633500223D3E /* GYAPISignatureResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYAPISignatureResponse.m; sourceTree = ""; }; + 81C9AF502805B665004A36A1 /* GYAPIPlatformInfoResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYAPIPlatformInfoResponse.h; sourceTree = ""; }; + 81C9AF512805B665004A36A1 /* GYAPIPlatformInfoResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYAPIPlatformInfoResponse.m; sourceTree = ""; }; + 81C9AF542805BA8A004A36A1 /* GYPlatformInfo+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GYPlatformInfo+Private.h"; sourceTree = ""; }; + 81C9AF562805BAB1004A36A1 /* GYPlatformInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYPlatformInfo.m; sourceTree = ""; }; + 81C9AF5A2805BB5B004A36A1 /* GYPlatformsInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYPlatformsInfo.m; sourceTree = ""; }; + 81C9AF5D2805BB82004A36A1 /* GYPlatformsInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYPlatformsInfo.h; path = Public/GYPlatformsInfo.h; sourceTree = ""; }; + 81C9AF5E2805BB82004A36A1 /* GYPlatformInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYPlatformInfo.h; path = Public/GYPlatformInfo.h; sourceTree = ""; }; + 81C9AF622805C36B004A36A1 /* GYPlatformInfoPaddle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYPlatformInfoPaddle.m; sourceTree = ""; }; + 81C9AF652805C386004A36A1 /* GYPlatformInfoPaddle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYPlatformInfoPaddle.h; path = Public/GYPlatformInfoPaddle.h; sourceTree = ""; }; + 81C9AF672805D2F3004A36A1 /* GYPlatformsInfo+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GYPlatformsInfo+Private.h"; sourceTree = ""; }; 81D8D495258B7193006BFE51 /* GlassfyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GlassfyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 81D8D497258B7193006BFE51 /* GlassfyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlassfyTests.swift; sourceTree = ""; }; 81D8D499258B7193006BFE51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -222,6 +239,8 @@ 816EF28C26611C5900513FB1 /* GYAPIPropertiesResponse.m */, 817C95682678F78400DB4945 /* GYAPISkuResponse.h */, 817C956A2678F7D300DB4945 /* GYAPISkuResponse.m */, + 81C9AF502805B665004A36A1 /* GYAPIPlatformInfoResponse.h */, + 81C9AF512805B665004A36A1 /* GYAPIPlatformInfoResponse.m */, 8138BAE225925705005CB44E /* Categories */, ); name = Data; @@ -286,6 +305,12 @@ 816EF2882661161200513FB1 /* GYUserProperties.m */, 818880BB27171DA900128A10 /* GYPaywallViewController.h */, 818880B827171D7A00128A10 /* GYPaywallViewController.m */, + 81C9AF5D2805BB82004A36A1 /* GYPlatformsInfo.h */, + 81C9AF5A2805BB5B004A36A1 /* GYPlatformsInfo.m */, + 81C9AF5E2805BB82004A36A1 /* GYPlatformInfo.h */, + 81C9AF562805BAB1004A36A1 /* GYPlatformInfo.m */, + 81C9AF652805C386004A36A1 /* GYPlatformInfoPaddle.h */, + 81C9AF622805C36B004A36A1 /* GYPlatformInfoPaddle.m */, 81951CD226443F82003901F1 /* GYTypes.h */, 81FCCE8527C3CE0A00DF3D1A /* GYPurchaseDelegate.h */, 816830B3258B6EA100565968 /* Core */, @@ -316,7 +341,8 @@ 81C2816825E3F6AC0048189D /* GYPermissions+Private.h */, 810F6FB725E50D2000D3009E /* GYOfferings+Private.h */, 816EF28F26611CF100513FB1 /* GYUserProperties+Private.h */, - 8168224627F1DB5E002B9857 /* GYPlatform.h */, + 81C9AF672805D2F3004A36A1 /* GYPlatformsInfo+Private.h */, + 81C9AF542805BA8A004A36A1 /* GYPlatformInfo+Private.h */, ); name = Core; sourceTree = ""; @@ -363,6 +389,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 81C9AF5F2805BB82004A36A1 /* GYPlatformsInfo.h in Headers */, 811BCDDF2608DA90007742D9 /* GYSysInfo.h in Headers */, 81951CE12644400B003901F1 /* GYError.h in Headers */, 8138BA8925924B42005CB44E /* SKProduct+GYEncode.h in Headers */, @@ -379,12 +406,13 @@ 8138BA9B25924C8F005CB44E /* SKProductDiscount+GYEncode.h in Headers */, 81C684652602633500223D3E /* GYAPISignatureResponse.h in Headers */, 811F31B726317ECD00777020 /* GYPermission+Private.h in Headers */, + 81C9AF682805D2F3004A36A1 /* GYPlatformsInfo+Private.h in Headers */, 811F31A826317EBB00777020 /* GYOfferings+Private.h in Headers */, 818880B52717153A00128A10 /* GYAPIPaywallResponse.h in Headers */, 81B49B552729A31C000BDDA1 /* GYFormatter.h in Headers */, - 8168224727F1DC5E002B9857 /* GYPlatform.h in Headers */, 811F31BC26317ED300777020 /* GYTransaction+Private.h in Headers */, 816EF29026611CF700513FB1 /* GYUserProperties+Private.h in Headers */, + 81C9AF602805BB82004A36A1 /* GYPlatformInfo.h in Headers */, 811F31B226317EC800777020 /* GYOffering+Private.h in Headers */, 81951CD326443F82003901F1 /* GYTypes.h in Headers */, 81951CD126443F65003901F1 /* Glassfy.h in Headers */, @@ -398,6 +426,7 @@ 816830B8258B6EE400565968 /* GYManager.h in Headers */, 817C95692678F79200DB4945 /* GYAPISkuResponse.h in Headers */, 8104537725909F320015A728 /* GYAPIInitResponse.h in Headers */, + 81C9AF522805B665004A36A1 /* GYAPIPlatformInfoResponse.h in Headers */, 8138BAA825924CDF005CB44E /* SKPaymentDiscount+GYEncode.h in Headers */, 8191E86B26690C850077BDD7 /* GYUserProperties.h in Headers */, 81951CDF26443FB8003901F1 /* GYPermission.h in Headers */, @@ -407,6 +436,7 @@ 8138BAA225924CB4005CB44E /* SKPaymentTransaction+GYEncode.h in Headers */, 8138BA5F25923E78005CB44E /* GYCodableProtocol.h in Headers */, 818880BE27171E1F00128A10 /* GYPaywallViewController+Private.h in Headers */, + 81C9AF662805C386004A36A1 /* GYPlatformInfoPaddle.h in Headers */, 81951CDB26443FAA003901F1 /* GYSku.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -516,11 +546,15 @@ 81E1DC3325933FC7003B5EBD /* SKPayment+GYEncode.m in Sources */, 8138BA9C25924C8F005CB44E /* SKProductDiscount+GYEncode.m in Sources */, 816830B9258B6EE400565968 /* GYManager.m in Sources */, + 81C9AF642805C36B004A36A1 /* GYPlatformInfoPaddle.m in Sources */, 811BCDE12608DA90007742D9 /* GYSysInfo.m in Sources */, + 81C9AF532805B665004A36A1 /* GYAPIPlatformInfoResponse.m in Sources */, 8161C4992594DD2F009CA563 /* GYTransaction.m in Sources */, 8138BA8A25924B42005CB44E /* SKProduct+GYEncode.m in Sources */, 817A1C4A258CCA7000D1BA10 /* GYSku.m in Sources */, 8179459126565E32000EAA47 /* GYUtils.m in Sources */, + 81C9AF5C2805BB5B004A36A1 /* GYPlatformsInfo.m in Sources */, + 81C9AF582805BAB1004A36A1 /* GYPlatformInfo.m in Sources */, 81C684662602633500223D3E /* GYAPISignatureResponse.m in Sources */, 817A1C3E258CC9EA00D1BA10 /* GYOffering.m in Sources */, 8161C42825948D82009CA563 /* GYError.m in Sources */, @@ -705,7 +739,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.3.0-beta.0; + MARKETING_VERSION = 1.3.0-beta.1; PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -733,7 +767,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.3.0-beta.0; + MARKETING_VERSION = 1.3.0-beta.1; PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/README.md b/README.md index b8ffc7e..4aa2ed1 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.0-beta.0'``` +```pod 'Glassfy', '~> 1.3.0-beta.1'``` Then, run the following command: diff --git a/Source/GYAPIManager.h b/Source/GYAPIManager.h index 7e176df..3cd4bfb 100644 --- a/Source/GYAPIManager.h +++ b/Source/GYAPIManager.h @@ -15,6 +15,7 @@ #import "GYAPIPropertiesResponse.h" #import "GYAPISkuResponse.h" #import "GYAPIPaywallResponse.h" +#import "GYAPIPlatformInfoResponse.h" @class SKProduct; @class SKPaymentTransaction; @class GYCacheManager; @@ -27,12 +28,13 @@ typedef void(^GYGetPropertiesCompletion)(GYAPIPropertiesResponse* _Nullable, NSE typedef void(^GYGetPaywallCompletion)(GYAPIPaywallResponse* _Nullable, NSError* _Nullable); typedef void(^GYGetSkuCompletion)(GYAPISkuResponse* _Nullable, NSError* _Nullable); typedef void(^GYBaseCompletion)(GYAPIBaseResponse* _Nullable, NSError* _Nullable); +typedef void(^GYGetPlatformInfo)(GYAPIPlatformInfoResponse* _Nullable, NSError* _Nullable); typedef GYBaseCompletion GYProductsCompletion; typedef GYBaseCompletion GYLogoutCompletion; typedef GYBaseCompletion GYLoginCompletion; typedef GYBaseCompletion GYPropertyCompletion; -typedef GYBaseCompletion GYPlatformCompletion; +typedef GYBaseCompletion GYGetConnectCompletion; NS_ASSUME_NONNULL_BEGIN @@ -63,8 +65,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)postProperty:(GYUserPropertyType)property obj:(id _Nullable)obj completion:(GYPropertyCompletion _Nullable)block; - (void)getPropertiesWithCompletion:(GYGetPropertiesCompletion _Nullable)block; -- (void)postConnectUser:(NSString *_Nullable)customId completion:(GYPlatformCompletion _Nullable)block; -- (void)postConnectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYPlatformCompletion _Nullable)block; +- (void)postConnectUser:(NSString *_Nullable)customId completion:(GYGetConnectCompletion _Nullable)block; +- (void)postConnectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYGetConnectCompletion _Nullable)block; + +- (void)getPlatformInfoWithCompletion:(GYGetPlatformInfo _Nullable)block; - (void)getSignatureForProductId:(NSString *)productId offerId:(NSString *)offerId completion:(GYGetSignatureCompletion _Nullable)block; diff --git a/Source/GYAPIManager.m b/Source/GYAPIManager.m index 8bec72c..9665a29 100644 --- a/Source/GYAPIManager.m +++ b/Source/GYAPIManager.m @@ -17,7 +17,6 @@ #import "GYLogger.h" #import "GYCacheManager.h" #import "GYUtils.h" -#import "GYPlatform.h" #define BASE_URL @"https://api.glassfy.io" @@ -328,7 +327,7 @@ - (void)postProperty:(GYUserPropertyType)property obj:(id _Nullable)obj completi } - (void)postConnectUser:(NSString *_Nullable)customId - completion:(GYPlatformCompletion _Nullable)block + completion:(GYGetConnectCompletion _Nullable)block { NSURLComponents *url = [self baseURLV0]; url.path = [url.path stringByAppendingPathComponent:@"connect"]; @@ -361,14 +360,14 @@ - (void)postConnectUser:(NSString *_Nullable)customId } - (void)postConnectPaddleLicenseKey:(NSString *)licenseKey - force:(BOOL)force - completion:(GYPlatformCompletion _Nullable)block + force:(BOOL)force + completion:(GYGetConnectCompletion _Nullable)block { NSURLComponents *url = [self baseURLV0]; url.path = [url.path stringByAppendingPathComponent:@"connect"]; NSDictionary *bodyEncoded = @{ - @"store": GYPlatformTypePaddle, + @"store": @(GYPlatformPaddle), @"licensekey": licenseKey, @"force": [NSNumber numberWithBool:force] }; @@ -398,6 +397,16 @@ - (void)postConnectPaddleLicenseKey:(NSString *)licenseKey [self callApiWithRequest:req response:GYAPIBaseResponse.class completion:block]; } + +- (void)getPlatformInfoWithCompletion:(GYGetPlatformInfo _Nullable)block +{ + NSURLComponents *url = [self baseURLV0]; + url.path = [url.path stringByAppendingPathComponent:@"platforminfo"]; + + NSURLRequest *req = [self authorizedRequestWithComponents:url]; + [self callApiWithRequest:req response:GYAPIPlatformInfoResponse.class completion:block]; +} + - (void)getPropertiesWithCompletion:(GYGetPropertiesCompletion _Nullable)block { NSURLComponents *url = [self baseURLV0]; diff --git a/Source/GYAPIPlatformInfoResponse.h b/Source/GYAPIPlatformInfoResponse.h new file mode 100644 index 0000000..df0923a --- /dev/null +++ b/Source/GYAPIPlatformInfoResponse.h @@ -0,0 +1,18 @@ +// +// GYAPIPlatformInfoResponse.h +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import +#import "GYAPIBaseResponse.h" +@class GYPlatformInfo; + +NS_ASSUME_NONNULL_BEGIN + +@interface GYAPIPlatformInfoResponse : GYAPIBaseResponse +@property(nonatomic, strong) NSArray *info; +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/GYAPIPlatformInfoResponse.m b/Source/GYAPIPlatformInfoResponse.m new file mode 100644 index 0000000..42831e1 --- /dev/null +++ b/Source/GYAPIPlatformInfoResponse.m @@ -0,0 +1,38 @@ +// +// GYAPIPlatformInfoResponse.m +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import "GYAPIPlatformInfoResponse.h" +#import "GYPlatformInfo+Private.h" + +@implementation GYAPIPlatformInfoResponse +- (instancetype _Nullable)initWithObject:(NSDictionary *)obj error:(NSError **)error +{ + self = [super initWithObject:obj error:error]; + if (error && *error) { + return self; + } + + if (self) { + NSMutableArray *platformsInfo = [NSMutableArray array]; + if ([obj[@"info"] isKindOfClass:NSArray.class]) { + NSArray *infoJSON = obj[@"info"]; + for (NSDictionary *platformInfoJSON in infoJSON) { + if (![platformInfoJSON isKindOfClass:NSDictionary.class]) { + continue; + } + + GYPlatformInfo *platformInfo = [[GYPlatformInfo alloc] initWithObject:platformInfoJSON error:nil]; + if (platformInfo) { + [platformsInfo addObject:platformInfo]; + } + } + } + self.info = platformsInfo; + } + return self; +} +@end diff --git a/Source/GYManager.h b/Source/GYManager.h index dd3af4a..0719a27 100644 --- a/Source/GYManager.h +++ b/Source/GYManager.h @@ -37,12 +37,14 @@ NS_ASSUME_NONNULL_BEGIN - (void)setExtraUserProperty:(NSDictionary *)extra completion:(GYErrorCompletion)block; - (void)getUserProperties:(GYUserPropertiesCompletion)block; -- (void)connectPaddleLicenseKey:(NSString *_Nullable)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block; +- (void)connectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block; - (void)connectCustomSubscriber:(NSString *_Nullable)customId completion:(GYErrorCompletion)block; - (void)getPaywall:(NSString *)paywallId completion:(GYPaywallCompletion)block API_UNAVAILABLE(macos, watchos); - (void)restorePurchasesWithCompletion:(GYPermissionsCompletion)block; + +- (void)platformInfo:(GYPlatformCompletion)block; @end NS_ASSUME_NONNULL_END diff --git a/Source/GYManager.m b/Source/GYManager.m index faa3024..68577cf 100644 --- a/Source/GYManager.m +++ b/Source/GYManager.m @@ -23,6 +23,7 @@ #import "GYOfferings+Private.h" #import "GYUserProperties+Private.h" #import "GYPaywallViewController+Private.h" +#import "GYPlatformsInfo+Private.h" #import "Glassfy+Private.h" #import "GYSysInfo.h" @@ -373,6 +374,20 @@ - (void)connectCustomSubscriber:(NSString *_Nullable)customId completion:(GYErro }]; } +- (void)platformInfo:(GYPlatformCompletion)block +{ + [self.api getPlatformInfoWithCompletion:^(GYAPIPlatformInfoResponse *res, NSError *err) { + GYPlatformsInfo *platformsInfo = [GYPlatformsInfo platformsInfoWithResponse:res]; + + typeof(block) __strong completion = block; + if (completion) { + dispatch_async(dispatch_get_main_queue(), ^{ + err ? completion(nil, err) : completion(platformsInfo, nil); + }); + } + }]; +} + #pragma mark - Notification - (void)applicationDidBecomeActive:(NSNotification *)notification diff --git a/Source/GYPlatform.h b/Source/GYPlatform.h deleted file mode 100644 index c787a58..0000000 --- a/Source/GYPlatform.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// GYPlatform.h -// Glassfy -// -// Created by Luca Garbolino on 28/03/22. -// - -#ifndef GYPlatform_h -#define GYPlatform_h - -typedef NSString * GYPlatformType; -#define GYPlatformTypePaddle @"3" - -#endif /* GYPlatform_h */ diff --git a/Source/GYPlatformInfo+Private.h b/Source/GYPlatformInfo+Private.h new file mode 100644 index 0000000..63f4a5c --- /dev/null +++ b/Source/GYPlatformInfo+Private.h @@ -0,0 +1,16 @@ +// +// GYPlatformInfo+Private.h.h +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import "GYPlatformInfo.h" +#import "GYCodableProtocol.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface GYPlatformInfo (Private) +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/GYPlatformInfo.m b/Source/GYPlatformInfo.m new file mode 100644 index 0000000..ef39e01 --- /dev/null +++ b/Source/GYPlatformInfo.m @@ -0,0 +1,51 @@ +// +// GYPlatformInfo.m +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import "GYPlatformInfo.h" +#import "GYPlatformInfoPaddle.h" +#import "GYLogger.h" + +@interface GYPlatformInfo() +@property(nonatomic, assign) GYPlatform platform; +@property(nonatomic, strong) NSDictionary *rawInfo; +@end + +@implementation GYPlatformInfo (Private) + +- (instancetype)initWithObject:(NSDictionary *)obj error:(NSError ** _Nullable)error +{ + NSString *platform = obj[@"platform"]; + if (![platform isKindOfClass:NSString.class] || platform.integerValue == 0) { + return nil; + } + + switch (platform.integerValue) { + case GYPlatformPaddle: + self = [GYPlatformInfoPaddle new]; + break; + case GYPlatformIos || GYPlatformAndroid: + self = [super init]; + break; + default: + GYLog(@"PLATFORM Unknown type: %@", platform); + self = [super init]; + break; + } + + if (self) { + NSMutableDictionary *rawInfo = [NSMutableDictionary dictionaryWithDictionary:obj]; + [rawInfo removeObjectForKey:@"platform"]; + self.rawInfo = rawInfo; + self.platform = platform.integerValue; + } + return self; +} + +@end + +@implementation GYPlatformInfo +@end diff --git a/Source/GYPlatformInfoPaddle.m b/Source/GYPlatformInfoPaddle.m new file mode 100644 index 0000000..c48d076 --- /dev/null +++ b/Source/GYPlatformInfoPaddle.m @@ -0,0 +1,58 @@ +// +// GYPlatformInfoPaddle.m +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import "GYPlatformInfoPaddle.h" + +@implementation GYPlatformInfoPaddle + +- (NSString *)userId +{ + NSString *userId = nil; + if ([self.rawInfo[@"userid"] isKindOfClass:NSString.class]) { + userId = self.rawInfo[@"userid"]; + } + return userId; +} + +- (NSString *)planId +{ + NSString *planId = nil; + if ([self.rawInfo[@"planid"] isKindOfClass:NSString.class]) { + planId = self.rawInfo[@"planid"]; + } + return planId; +} + +- (NSString *)subscriptionId +{ + NSString *subscriptionId = nil; + if ([self.rawInfo[@"subscriptionid"] isKindOfClass:NSString.class]) { + subscriptionId = self.rawInfo[@"subscriptionid"]; + } + return subscriptionId; +} + +- (NSURL *)updateURL +{ + NSURL *updateURL = nil; + if ([self.rawInfo[@"updateurl"] isKindOfClass:NSString.class]) { + updateURL = [NSURL URLWithString:self.rawInfo[@"updateurl"]]; + } + return updateURL; +} + +- (NSURL *)cancelURL +{ + NSURL *cancelURL = nil; + if ([self.rawInfo[@"cancelurl"] isKindOfClass:NSString.class]) { + cancelURL = [NSURL URLWithString:self.rawInfo[@"cancelurl"]]; + } + return cancelURL; +} + + +@end diff --git a/Source/GYPlatformsInfo+Private.h b/Source/GYPlatformsInfo+Private.h new file mode 100644 index 0000000..98e7025 --- /dev/null +++ b/Source/GYPlatformsInfo+Private.h @@ -0,0 +1,17 @@ +// +// GYPlatformInfo+Private.h.h +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import "GYPlatformsInfo.h" +#import "GYCodableProtocol.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface GYPlatformsInfo (Private) ++ (instancetype)platformsInfoWithResponse:(GYAPIPlatformInfoResponse *_Nullable)response; +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/GYPlatformsInfo.m b/Source/GYPlatformsInfo.m new file mode 100644 index 0000000..0fa4889 --- /dev/null +++ b/Source/GYPlatformsInfo.m @@ -0,0 +1,34 @@ +// +// GYPlatformsInfo.m +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import "GYPlatformsInfo.h" +#import "GYAPIPlatformInfoResponse.h" + +@interface GYPlatformsInfo() +@property(nonatomic, strong) NSArray *all; +@end + +@implementation GYPlatformsInfo (Private) + ++ (instancetype)platformsInfoWithResponse:(GYAPIPlatformInfoResponse *_Nullable)response +{ + GYPlatformsInfo *platformsInfo = [[self alloc] init]; + platformsInfo.all = response.info ?: @[]; + + return platformsInfo; +} + +@end + +@implementation GYPlatformsInfo + +- (NSArray *)filter:(GYPlatform)type +{ + return [self.all filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"platform == %@", @(type)]]; +} + +@end diff --git a/Source/Glassfy.m b/Source/Glassfy.m index 928b734..d48610a 100644 --- a/Source/Glassfy.m +++ b/Source/Glassfy.m @@ -40,7 +40,7 @@ + (Glassfy *)shared + (NSString *)sdkVersion { - return @"1.3.0-beta.0"; + return @"1.3.0-beta.1"; } + (void)initializeWithAPIKey:(NSString *)apiKey @@ -167,12 +167,12 @@ + (void)setPurchaseDelegate:(id)delegate }); } -+ (void)connectPaddleLicenseKey:(NSString *_Nullable)licenseKey completion:(GYErrorCompletion)block ++ (void)connectPaddleLicenseKey:(NSString *)licenseKey completion:(GYErrorCompletion)block { [self connectPaddleLicenseKey:licenseKey force:NO completion:block]; } -+ (void)connectPaddleLicenseKey:(NSString *_Nullable)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block ++ (void)connectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block { dispatch_async(Glassfy.shared.glqueue, ^{ [Glassfy.shared.manager connectPaddleLicenseKey:licenseKey force:force completion:block]; @@ -186,6 +186,12 @@ + (void)connectCustomSubscriber:(NSString *_Nullable)customId completion:(GYErro }); } ++ (void)platformInfo:(GYPlatformCompletion)block +{ + dispatch_async(Glassfy.shared.glqueue, ^{ + [Glassfy.shared.manager platformInfo:block]; + }); +} #pragma mark - Deprecations diff --git a/Source/Public/GYPlatformInfo.h b/Source/Public/GYPlatformInfo.h new file mode 100644 index 0000000..8775c40 --- /dev/null +++ b/Source/Public/GYPlatformInfo.h @@ -0,0 +1,23 @@ +// +// GYPlatformInfo.h +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import +#if __has_include() +#import +#else +#import "GYTypes.h" +#endif + +NS_ASSUME_NONNULL_BEGIN + +NS_SWIFT_NAME(Glassfy.PlatformInfo) +@interface GYPlatformInfo : NSObject +@property(nonatomic, readonly) GYPlatform platform; +@property(nonatomic, readonly) NSDictionary *rawInfo; +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/Public/GYPlatformInfoPaddle.h b/Source/Public/GYPlatformInfoPaddle.h new file mode 100644 index 0000000..2f30f12 --- /dev/null +++ b/Source/Public/GYPlatformInfoPaddle.h @@ -0,0 +1,28 @@ +// +// GYPlatformInfoPaddle.h +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import +#if __has_include() +#import +#else +#import "GYPlatformInfo.h" +#endif + + +NS_ASSUME_NONNULL_BEGIN + +NS_SWIFT_NAME(Glassfy.PlatformInfoPaddle) +@interface GYPlatformInfoPaddle : GYPlatformInfo +@property(nonatomic, nullable, readonly) NSString *userId; +@property(nonatomic, nullable, readonly) NSString *planId; +@property(nonatomic, nullable, readonly) NSString *subscriptionId; + +@property(nonatomic, nullable, readonly) NSURL *updateURL; +@property(nonatomic, nullable, readonly) NSURL *cancelURL; +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/Public/GYPlatformsInfo.h b/Source/Public/GYPlatformsInfo.h new file mode 100644 index 0000000..71b4511 --- /dev/null +++ b/Source/Public/GYPlatformsInfo.h @@ -0,0 +1,25 @@ +// +// GYPlatformsInfo.h +// Glassfy +// +// Created by Luca Garbolino on 12/04/22. +// + +#import +#if __has_include() +#import +#else +#import "GYTypes.h" +#endif +@class GYPlatformInfo; + +NS_ASSUME_NONNULL_BEGIN + +NS_SWIFT_NAME(Glassfy.PlatformsInfo) +@interface GYPlatformsInfo : NSObject +@property(nonatomic, readonly) NSArray *all; + +- (NSArray *)filter:(GYPlatform)type; +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/Public/GYTypes.h b/Source/Public/GYTypes.h index 8a172c8..c6fe084 100644 --- a/Source/Public/GYTypes.h +++ b/Source/Public/GYTypes.h @@ -14,6 +14,7 @@ @class GYPermissions; @class GYOfferings; @class GYUserProperties; +@class GYPlatformsInfo; @class GYSku; @class GYPaywallViewController; @@ -26,6 +27,7 @@ typedef void(^GYPermissionsCompletion)(GYPermissions* _Nullable, NSError* _Nulla typedef void(^GYBooleanCompletion)(BOOL, NSError* _Nullable) NS_SWIFT_NAME(Glassfy.BooleanCompletion); typedef void(^GYErrorCompletion)(NSError* _Nullable) NS_SWIFT_NAME(Glassfy.ErrorCompletion); typedef void(^GYUserPropertiesCompletion)(GYUserProperties* _Nullable, NSError* _Nullable) NS_SWIFT_NAME(Glassfy.UserPropertiesCompletion); +typedef void(^GYPlatformCompletion)(GYPlatformsInfo* _Nullable, NSError* _Nullable) NS_SWIFT_NAME(Glassfy.PlatformCompletion); typedef void(^GYPaywallCompletion)(GYPaywallViewController* _Nullable, NSError* _Nullable) NS_SWIFT_NAME(Glassfy.PaywallCompletion); typedef void(^GYPaywallCloseBlock)(GYTransaction* _Nullable, NSError* _Nullable) NS_SWIFT_NAME(Glassfy.PaywallCloseBlock); typedef void(^GYPaywallLinkBlock)(NSURL*) NS_SWIFT_NAME(Glassfy.PaywallLinkBlock); @@ -87,6 +89,12 @@ typedef NS_ENUM(NSUInteger, GYLogLevel) { GYLogLevelAll = NSUIntegerMax } NS_SWIFT_NAME(Glassfy.LogLevel); +typedef NS_ENUM(NSUInteger, GYPlatform) { + GYPlatformIos = 1, + GYPlatformAndroid = 2, + GYPlatformPaddle = 3 +} NS_SWIFT_NAME(Glassfy.Platform); + NS_ASSUME_NONNULL_END #endif /* Types_h */ diff --git a/Source/Public/Glassfy.h b/Source/Public/Glassfy.h index a8b434e..4b48653 100644 --- a/Source/Public/Glassfy.h +++ b/Source/Public/Glassfy.h @@ -21,6 +21,8 @@ #import #import #import +#import +#import #else #import "GYSku.h" #import "GYOffering.h" @@ -34,6 +36,8 @@ #import "GYTypes.h" #import "GYError.h" #import "GYPurchaseDelegate.h" +#import "GYPlatformsInfo.h" +#import "GYPlatformInfoPaddle.h" #endif @@ -71,21 +75,6 @@ NS_ASSUME_NONNULL_BEGIN */ + (void)initializeWithAPIKey:(NSString *)apiKey watcherMode:(BOOL)watcherMode NS_SWIFT_NAME(initialize(apiKey:watcherMode:)); -/** - Customize User Identifier to identify user across devices - - @param userId UserId to identify user across devices. Passing nil is equivalent to call logout API - @param block Completion block called after login - */ -+ (void)loginUser:(NSString *_Nullable)userId withCompletion:(GYErrorCompletion _Nullable)block NS_SWIFT_NAME(login(user:completion:)); - -/** - Remove associations between user and userID - - @param block Completion block called after log out - */ -+ (void)logoutWithCompletion:(GYErrorCompletion _Nullable)block NS_SWIFT_NAME(logout(completion:)); - /** Chek permissions status of the user @@ -211,7 +200,7 @@ Save extra user properties @param block Completion block @note Check error code in GYDomain - GYErrorCodeLicenseAlreadyConnected, GYErrorCodeLicenseNotFound to handle those cases */ -+ (void)connectPaddleLicenseKey:(NSString *_Nullable)licenseKey completion:(GYErrorCompletion)block NS_SWIFT_NAME(connectPaddle(licenseKey:completion:)); ++ (void)connectPaddleLicenseKey:(NSString *)licenseKey completion:(GYErrorCompletion)block NS_SWIFT_NAME(connectPaddle(licenseKey:completion:)); /** Connect paddle license key @@ -221,7 +210,7 @@ Save extra user properties @param block Completion block @note Check error code in GYDomain - GYErrorCodeLicenseAlreadyConnected, GYErrorCodeLicenseInvalid to handle those cases */ -+ (void)connectPaddleLicenseKey:(NSString *_Nullable)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block NS_SWIFT_NAME(connectPaddle(licenseKey:force:completion:)); ++ (void)connectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block NS_SWIFT_NAME(connectPaddle(licenseKey:force:completion:)); /** Connect custom subscriber @@ -231,8 +220,30 @@ Save extra user properties */ + (void)connectCustomSubscriber:(NSString *_Nullable)customId completion:(GYErrorCompletion)block NS_SWIFT_NAME(connectCustomSubscriber(_:completion:)); +/** + Info about user connected platforms + + @param block Completion block + */ ++ (void)platformInfo:(GYPlatformCompletion)block NS_SWIFT_NAME(platformInfo(completion:)); + + /// Deprecations + +/** +@warning Deprecated in favour of `+skuWithId:completion:` +*/ + (void)skuWithIdentifier:(NSString *)skuid completion:(GYSkuBlock)block NS_SWIFT_NAME(sku(identifier:completion:)) __attribute__((deprecated("Renamed to +skuWithId:completion:"))); + +/** + @warning Deprecated in favour of `+connectCustomSubscriber:completion:` + */ ++ (void)loginUser:(NSString *_Nullable)userId withCompletion:(GYErrorCompletion _Nullable)block NS_SWIFT_NAME(login(user:completion:)) __attribute__((deprecated())); + +/** + @warning Deprecated in favour of `+connectCustomSubscriber:completion:` + */ ++ (void)logoutWithCompletion:(GYErrorCompletion _Nullable)block NS_SWIFT_NAME(logout(completion:)) __attribute__((deprecated())); @end NS_ASSUME_NONNULL_END