Commit 0a69d7c5 by Dima Bart

Remove static version declaration. Refactor dynamic version declaration

parent 1d6d4d7a
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#import "BUYSerializable.h" #import "BUYSerializable.h"
static NSString * const BUYShopifyErrorDomain = @"BUYShopifyErrorDomain"; static NSString * const BUYShopifyErrorDomain = @"BUYShopifyErrorDomain";
static NSString * const BUYClientVersionString = @"2.0";
static NSString * const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token"; static NSString * const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token";
typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResponse *response, NSError *error); typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResponse *response, NSError *error);
......
...@@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong, readonly, nonnull) NSString *appId; @property (nonatomic, strong, readonly, nonnull) NSString *appId;
/** /**
* Application name to attribute orders to. Defaults to app bundle name (CFBundleName) * Application name to attribute orders to. Uses the app bundle name from info.plist (CFBundleName)
*/ */
@property (nonatomic, strong, nonnull) NSString *applicationName; @property (nonatomic, strong, nonnull) NSString *applicationName;
......
...@@ -71,20 +71,35 @@ static NSString * const BUYClientJSONMimeType = @"application/json"; ...@@ -71,20 +71,35 @@ static NSString * const BUYClientJSONMimeType = @"application/json";
#pragma mark - Headers - #pragma mark - Headers -
- (NSBundle *)sdkBundle
{
return [NSBundle bundleForClass:[self class]];
}
- (NSString *)sdkVersion
{
return [[self sdkBundle] objectForInfoDictionaryKey:(id)kCFBundleVersionKey] ?: @"";
}
- (NSBundle *)appBundle
{
return [NSBundle mainBundle];
}
- (NSString *)applicationName - (NSString *)applicationName
{ {
return [[NSBundle mainBundle] infoDictionary][@"CFBundleName"] ?: @""; return [[self appBundle] objectForInfoDictionaryKey:(id)kCFBundleNameKey] ?: @"";
} }
- (NSString *)bundleIdentifier - (NSString *)appBundleIdentifier
{ {
return [[NSBundle mainBundle] bundleIdentifier]; return [[self appBundle] bundleIdentifier];
} }
- (NSDictionary *)additionalHeaders - (NSDictionary *)additionalHeaders
{ {
return @{ return @{
@"User-Agent": [NSString stringWithFormat:@"Mobile Buy SDK iOS/%@/%@", BUYClientVersionString, [self bundleIdentifier]] @"User-Agent": [NSString stringWithFormat:@"Mobile Buy SDK iOS/%@/%@", [self sdkVersion], [self appBundleIdentifier]]
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment