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.8
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarbo committed Apr 5, 2023
1 parent eae4e00 commit 5395dff
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 48 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.7"
s.version = "1.3.8"
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
4 changes: 2 additions & 2 deletions Glassfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.7;
MARKETING_VERSION = 1.3.8;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -857,7 +857,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.7;
MARKETING_VERSION = 1.3.8;
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.7'```
```pod 'Glassfy', '~> 1.3.8'```

Then, run the following command:

Expand Down
9 changes: 8 additions & 1 deletion Source/GYAPIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getPropertiesWithCompletion:(GYGetPropertiesCompletion _Nullable)block;

- (void)postConnectUser:(NSString *_Nullable)customId completion:(GYGetConnectCompletion _Nullable)block;
- (void)postConnectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYGetConnectCompletion _Nullable)block;

- (void)postConnectPaddleLicenseKey:(NSString *)licenseKey
force:(BOOL)force
completion:(GYGetConnectCompletion _Nullable)block;

- (void)postConnectGlassfyUniversalCode:(NSString *)universalCode
force:(BOOL)force
completion:(GYGetConnectCompletion _Nullable)block;

- (void)getStoreInfoWithCompletion:(GYGetStoreInfo _Nullable)block;

Expand Down
67 changes: 55 additions & 12 deletions Source/GYAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
//

#import <CommonCrypto/CommonDigest.h>
#import "Glassfy+Private.h"
#import "GYUserProperties+Private.h"
#import "GYSku+Private.h"
#import "SKPaymentTransaction+GYEncode.h"
#import "SKProduct+GYEncode.h"
#import "GYAttributionItem+Private.h"
#import "GYSysInfo.h"
#import "GYAPIManager.h"
#import "GYAttributionItem+Private.h"
#import "GYCacheManager.h"
#import "GYError.h"
#import "GYLogger.h"
#import "GYCacheManager.h"
#import "GYSku+Private.h"
#import "GYSysInfo.h"
#import "GYUserProperties+Private.h"
#import "GYUtils.h"
#import "Glassfy+Private.h"
#import "SKPaymentTransaction+GYEncode.h"
#import "SKProduct+GYEncode.h"

#define BASE_URL @"https://api.glassfy.io"

Expand Down Expand Up @@ -99,6 +99,11 @@ - (void)getInitWithCrossPlatformSdkFramework:(NSString *)framework
if (version) {
[queryItems addObject:[NSURLQueryItem queryItemWithName:@"cross_platform_sdk_version" value:version]];
}
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
if (bundleIdentifier) {
NSURLQueryItem *bundleIdentifierItem = [NSURLQueryItem queryItemWithName:@"bundle_id" value:bundleIdentifier];
[queryItems addObject:bundleIdentifierItem];
}
url.queryItems = queryItems;

NSURLRequest *req = [self authorizedRequestWithComponents:url];
Expand Down Expand Up @@ -405,8 +410,7 @@ - (void)postConnectPaddleLicenseKey:(NSString *)licenseKey
NSData *body;
if (![NSJSONSerialization isValidJSONObject:bodyEncoded]) {
err = GYError.encodeData;
}
else {
} else {
body = [NSJSONSerialization dataWithJSONObject:bodyEncoded options:kNilOptions error:&err];
}
if (err) {
Expand Down Expand Up @@ -475,8 +479,7 @@ - (void)postAttributions:(NSArray<GYAttributionItem*> *)items withCompletion:(GY
NSData *body;
if (![NSJSONSerialization isValidJSONObject:bodyEncoded]) {
err = GYError.encodeData;
}
else {
} else {
body = [NSJSONSerialization dataWithJSONObject:bodyEncoded options:kNilOptions error:&err];
}
if (err) {
Expand Down Expand Up @@ -505,6 +508,46 @@ - (void)getPurchaseHistoryWithCompletion:(GYGetPurchaseHistoryCompletion _Nullab
[self callApiWithRequest:req response:GYAPIPurchaseHistoryResponse.class completion:block];
}

- (void)postConnectGlassfyUniversalCode:(NSString*)universalCode
force:(BOOL)force
completion:(GYGetConnectCompletion _Nullable)block
{
NSDictionary *payload = @{
@"licenseKey": universalCode,
@"store": @(GYStoreGlassfy),
@"force": @(force)
};

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

NSURLComponents *url = [self baseURLV0];
url.path = [url.path stringByAppendingPathComponent:@"connect"];

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
47 changes: 38 additions & 9 deletions Source/GYManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,64 @@ NS_ASSUME_NONNULL_BEGIN

- (void)setPurchaseDelegate:(id<GYPurchaseDelegate>)delegate;

- (void)loginUser:(NSString *_Nullable)userId withCompletion:(GYErrorCompletion _Nullable)block;
- (void)loginUser:(NSString *_Nullable)userId
withCompletion:(GYErrorCompletion _Nullable)block;

- (void)logoutWithCompletion:(GYErrorCompletion _Nullable)block;

- (void)permissionsWithCompletion:(GYPermissionsCompletion)block;

- (void)offeringsWithCompletion:(GYOfferingsCompletion)block;

- (void)skuWithId:(NSString *)skuid completion:(GYSkuBlock)block;

- (void)skuWithId:(NSString *)skuId store:(GYStore)store completion:(GYSkuBaseCompletion)block;
- (void)skuWithProductId:(NSString *)productid promotionalId:(NSString *_Nullable)promoid completion:(GYSkuBlock)block;

- (void)skuWithProductId:(NSString *)productid
promotionalId:(NSString *_Nullable)promoid
completion:(GYSkuBlock)block;

- (void)purchaseSku:(GYSku *)sku completion:(GYPaymentTransactionBlock)block;
- (void)purchaseSku:(GYSku *)sku withDiscount:(SKProductDiscount *_Nullable)discount completion:(GYPaymentTransactionBlock)block API_AVAILABLE(ios(12.2), macos(10.14.4), watchos(6.2));

- (void)purchaseSku:(GYSku *)sku
withDiscount:(SKProductDiscount *_Nullable)discount
completion:(GYPaymentTransactionBlock)block
API_AVAILABLE(ios(12.2), macos(10.14.4), watchos(6.2));

- (void)setEmailUserProperty:(NSString *)email completion:(GYErrorCompletion)block;

- (void)setDeviceToken:(NSString *)deviceToken completion:(GYErrorCompletion)block;
- (void)setExtraUserProperty:(NSDictionary<NSString*,NSString*> *)extra completion:(GYErrorCompletion)block;

- (void)setExtraUserProperty:(NSDictionary<NSString*,NSString*> *)extra
completion:(GYErrorCompletion)block;

- (void)getUserProperties:(GYUserPropertiesCompletion)block;

- (void)connectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force completion:(GYErrorCompletion)block;
- (void)connectCustomSubscriber:(NSString *_Nullable)customId completion:(GYErrorCompletion)block;
- (void)connectPaddleLicenseKey:(NSString *)licenseKey
force:(BOOL)force
completion:(GYErrorCompletion)block;

- (void)connectGlassfyUniversalCode:(NSString*)universalCode
force:(BOOL)force
withCompletion:(GYErrorCompletion)block;

- (void)getPaywall:(NSString *)paywallId completion:(GYPaywallCompletion)block API_UNAVAILABLE(macos, watchos);
- (void)connectCustomSubscriber:(NSString *_Nullable)customId
completion:(GYErrorCompletion)block;

- (void)getPaywall:(NSString *)paywallId
completion:(GYPaywallCompletion)block
API_UNAVAILABLE(macos, watchos);

- (void)restorePurchasesWithCompletion:(GYPermissionsCompletion)block;

- (void)storeInfo:(GYStoreCompletion)block;

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

- (void)setAttributions:(NSArray<GYAttributionItem*> *)attributions
completion:(GYErrorCompletion)block;

- (void)purchaseHistoryWithCompletion:(GYPurchaseHistoryCompletion)block;

Expand Down
16 changes: 15 additions & 1 deletion Source/GYManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,21 @@ - (void)connectPaddleLicenseKey:(NSString *)licenseKey force:(BOOL)force complet
}];
}

- (void)connectGlassfyUniversalCode:(NSString*)universalCode
force:(BOOL)force
withCompletion:(GYErrorCompletion)block
{
[self.api postConnectGlassfyUniversalCode:universalCode force:force completion:^(GYAPIBaseResponse *res, NSError *err) {
typeof(block) __strong completion = block;
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(err);
});
}
}];

}

- (void)connectCustomSubscriber:(NSString *_Nullable)customId completion:(GYErrorCompletion)block
{
[self.api postConnectUser:customId completion:^(GYAPIBaseResponse *res, NSError *err) {
Expand Down Expand Up @@ -432,7 +447,6 @@ - (void)purchaseHistoryWithCompletion:(GYPurchaseHistoryCompletion)block
[self purchaseHistoryMaxRetries:10 completion:block];
}


#pragma mark - Notification

- (void)applicationDidBecomeActive:(NSNotification *)notification
Expand Down
13 changes: 12 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.7";
return @"1.3.8";
}

+ (void)initializeWithAPIKey:(NSString *)apiKey
Expand Down Expand Up @@ -229,6 +229,17 @@ + (void)purchaseHistoryWithCompletion:(GYPurchaseHistoryCompletion)block
});
}

+ (void)connectGlassfyUniversalCode:(NSString*)universalCode
force:(BOOL)force
withCompletion:(GYErrorCompletion)block
{
dispatch_async(Glassfy.shared.glqueue, ^{
[Glassfy.shared.manager connectGlassfyUniversalCode:universalCode
force:force
withCompletion:block];
});
}

#pragma mark - Deprecations

+ (void)skuWithIdentifier:(NSString *)skuid completion:(GYSkuBlock)block
Expand Down
36 changes: 19 additions & 17 deletions Source/Public/GYError.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@ typedef NS_ERROR_ENUM(GYErrorDomain, GYErrorCode) {
GYErrorCodeSizeLimit,
GYErrorCodeWrongParameterType,
GYErrorCodeAPINotSupported,
GYErrorCodeInvalidAPIToken = 1000,
GYErrorCodeSubscriberIDNotFound = 1001,
GYErrorCodeInstallationIDNotFound = 1002,
GYErrorCodeStoreTypeNotFound = 1003,
GYErrorCodeWrongStoreType = 1004,
GYErrorCodeGenericError = 1005,
GYErrorCodeInvalidAppID = 1006,
GYErrorCodeUnauthorized = 1007,
GYErrorCodeSkuIDNotFound = 1008,
GYErrorCodeAppIDNotFound = 1009,
GYErrorCodeInvalidParameter = 1010,
GYErrorCodeAppleReceiptStatusError = 1011,
GYErrorCodeInvalidFieldValueError = 1012,
GYErrorCodeInvalidFieldNameError = 1013,
GYErrorCodeLicenseAlreadyConnected = 1050,
GYErrorCodeLicenseNotFound = 1051,
GYErrorCodeUnknow = -1
GYErrorCodeInvalidAPIToken = 1000,
GYErrorCodeSubscriberIDNotFound = 1001,
GYErrorCodeInstallationIDNotFound = 1002,
GYErrorCodeStoreTypeNotFound = 1003,
GYErrorCodeWrongStoreType = 1004,
GYErrorCodeGenericError = 1005,
GYErrorCodeInvalidAppID = 1006,
GYErrorCodeUnauthorized = 1007,
GYErrorCodeSkuIDNotFound = 1008,
GYErrorCodeAppIDNotFound = 1009,
GYErrorCodeInvalidParameter = 1010,
GYErrorCodeAppleReceiptStatusError = 1011,
GYErrorCodeInvalidFieldValueError = 1012,
GYErrorCodeInvalidFieldNameError = 1013,
GYErrorCodeLicenseAlreadyConnected = 1050,
GYErrorCodeLicenseNotFound = 1051,
GYErrorCodeUniversalCodeAlreadyConnected = GYErrorCodeLicenseAlreadyConnected,
GYErrorCodeUniversalCodeNotFound = GYErrorCodeLicenseNotFound,
GYErrorCodeUnknow = -1
} NS_SWIFT_NAME(Glassfy.ErrorCode);

NS_SWIFT_NAME(Glassfy.Error)
Expand Down
4 changes: 3 additions & 1 deletion Source/Public/GYTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ typedef NS_ENUM(NSUInteger, GYLogLevel) {
typedef NS_ENUM(NSUInteger, GYStore) {
GYStoreAppStore = 1,
GYStorePlayStore = 2,
GYStorePaddle = 3
GYStorePaddle = 3,
GYStoreStripe = 4,
GYStoreGlassfy = 5
} NS_SWIFT_NAME(Glassfy.Store);

typedef NS_ENUM(NSUInteger, GYAttributionType) {
Expand Down
17 changes: 15 additions & 2 deletions Source/Public/Glassfy.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,21 @@ Save extra user properties
@param block Completion block
@note Check error code in GYDomain - GYErrorCodeLicenseAlreadyConnected, GYErrorCodeLicenseInvalid to handle those cases
*/
+ (void)connectPaddleLicenseKey:(NSString *)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 Glassfy Universal Code
@param universalCode Glassfy Universal Code
@param force Disconnect the code from other subscriber(s) and connect with current subscriber
@param block Completion block
@note Check error code in GYDomain - GYErrorCodeUniversalCodeAlreadyConnected, GYErrorCodeUniversalCodeNotFound to handle those cases
*/
+ (void)connectGlassfyUniversalCode:(NSString *)universalCode
force:(BOOL)force
withCompletion:(GYErrorCompletion)block NS_SWIFT_NAME(connectGlassfy(universalCode:force:completion:));

/**
Connect custom subscriber
Expand Down Expand Up @@ -281,7 +295,6 @@ Purchase history
*/
+ (void)purchaseHistoryWithCompletion:(GYPurchaseHistoryCompletion)block;


/// Deprecations

/**
Expand Down

0 comments on commit 5395dff

Please sign in to comment.