diff --git a/Pod/Classes/SEGAdjustAppSecret.h b/Pod/Classes/SEGAdjustAppSecret.h new file mode 100644 index 0000000..37655d0 --- /dev/null +++ b/Pod/Classes/SEGAdjustAppSecret.h @@ -0,0 +1,18 @@ +#import + + +@interface SEGAdjustAppSecret : NSObject + +@property (nonatomic, readonly) NSUInteger ID; +@property (nonatomic, readonly) NSUInteger info1; +@property (nonatomic, readonly) NSUInteger info2; +@property (nonatomic, readonly) NSUInteger info3; +@property (nonatomic, readonly) NSUInteger info4; + +- (instancetype)initWithID:(NSUInteger)ID + info1:(NSUInteger)info1 + info2:(NSUInteger)info2 + info3:(NSUInteger)info3 + info4:(NSUInteger)info4; + +@end diff --git a/Pod/Classes/SEGAdjustAppSecret.m b/Pod/Classes/SEGAdjustAppSecret.m new file mode 100644 index 0000000..ffce70f --- /dev/null +++ b/Pod/Classes/SEGAdjustAppSecret.m @@ -0,0 +1,34 @@ +#import "SEGAdjustAppSecret.h" + + +@interface SEGAdjustAppSecret () + +@property (nonatomic, assign) NSUInteger ID; +@property (nonatomic, assign) NSUInteger info1; +@property (nonatomic, assign) NSUInteger info2; +@property (nonatomic, assign) NSUInteger info3; +@property (nonatomic, assign) NSUInteger info4; + +@end + + +@implementation SEGAdjustAppSecret + +#pragma mark - Initialization + +- (instancetype)initWithID:(NSUInteger)ID + info1:(NSUInteger)info1 + info2:(NSUInteger)info2 + info3:(NSUInteger)info3 + info4:(NSUInteger)info4 { + if (self = [super init]) { + self.ID = ID; + self.info1 = info1; + self.info2 = info2; + self.info3 = info3; + self.info4 = info4; + } + return self; +} + +@end diff --git a/Pod/Classes/SEGAdjustIntegration.h b/Pod/Classes/SEGAdjustIntegration.h index 28aebab..c375c09 100644 --- a/Pod/Classes/SEGAdjustIntegration.h +++ b/Pod/Classes/SEGAdjustIntegration.h @@ -8,6 +8,6 @@ @property (nonatomic, strong) NSDictionary *settings; @property (nonatomic, strong) SEGAnalytics *analytics; -- (instancetype)initWithSettings:(NSDictionary *)settings withAnalytics:(SEGAnalytics *)analytics; +- (instancetype)initWithAppSecret:(nullable NSArray *)secret settings:(NSDictionary *)settings analytics:(SEGAnalytics *)analytics; @end diff --git a/Pod/Classes/SEGAdjustIntegration.m b/Pod/Classes/SEGAdjustIntegration.m index 6301600..5431c26 100644 --- a/Pod/Classes/SEGAdjustIntegration.m +++ b/Pod/Classes/SEGAdjustIntegration.m @@ -1,12 +1,21 @@ #import "SEGAdjustIntegration.h" +#import "SEGAdjustAppSecret.h" #import +@interface ADJConfig () +- (void)setAppSecret:(NSUInteger)secretId + info1:(NSUInteger)info1 + info2:(NSUInteger)info2 + info3:(NSUInteger)info3 + info4:(NSUInteger)info4; +@end + @implementation SEGAdjustIntegration #pragma mark - Initialization -- (instancetype)initWithSettings:(NSDictionary *)settings withAnalytics:(SEGAnalytics *)analytics +- (instancetype)initWithAppSecret:(nullable SEGAdjustAppSecret *)secret settings:(NSDictionary *)settings analytics:(SEGAnalytics *)analytics { if (self = [super init]) { self.settings = settings; @@ -22,6 +31,19 @@ - (instancetype)initWithSettings:(NSDictionary *)settings withAnalytics:(SEGAnal ADJConfig *adjustConfig = [ADJConfig configWithAppToken:appToken environment:environment]; + if (secret != nil) { + if ([adjustConfig respondsToSelector: @selector(setAppSecret:info1:info2:info3:info4:)]) { + + [adjustConfig setAppSecret:secret.ID + info1:secret.info1 + info2:secret.info2 + info3:secret.info3 + info4:secret.info4]; + } else { + SEGLog(@"App secret not supported by current Adjust version"); + } + } + if ([self setEventBufferingEnabled]) { [adjustConfig setEventBufferingEnabled:YES]; } diff --git a/Pod/Classes/SEGAdjustIntegrationFactory.h b/Pod/Classes/SEGAdjustIntegrationFactory.h index 2fce063..d412507 100644 --- a/Pod/Classes/SEGAdjustIntegrationFactory.h +++ b/Pod/Classes/SEGAdjustIntegrationFactory.h @@ -1,9 +1,12 @@ #import #import +@class SEGAdjustAppSecret; + @interface SEGAdjustIntegrationFactory : NSObject + (instancetype)instance; ++ (instancetype)instanceWithAppSecret:(nullable SEGAdjustAppSecret *)secret NS_SWIFT_NAME(instance(appSecret:)); @end diff --git a/Pod/Classes/SEGAdjustIntegrationFactory.m b/Pod/Classes/SEGAdjustIntegrationFactory.m index a894ea1..8643d73 100644 --- a/Pod/Classes/SEGAdjustIntegrationFactory.m +++ b/Pod/Classes/SEGAdjustIntegrationFactory.m @@ -1,28 +1,36 @@ #import "SEGAdjustIntegrationFactory.h" #import "SEGAdjustIntegration.h" +#import "SEGAdjustAppSecret.h" -@implementation SEGAdjustIntegrationFactory +@implementation SEGAdjustIntegrationFactory { + SEGAdjustAppSecret *appSecret; +} + ++ (instancetype)instance { + return [self instanceWithAppSecret: nil]; +} -+ (instancetype)instance ++ (instancetype)instanceWithAppSecret: (nullable SEGAdjustAppSecret *)secret { static dispatch_once_t once; static SEGAdjustIntegrationFactory *sharedInstance; dispatch_once(&once, ^{ - sharedInstance = [[self alloc] init]; + sharedInstance = [[self alloc] initWithAppSecret: secret]; }); return sharedInstance; } -- (instancetype)init +- (instancetype)initWithAppSecret: (SEGAdjustAppSecret *)secret { self = [super init]; + appSecret = secret; return self; } - (id)createWithSettings:(NSDictionary *)settings forAnalytics:(SEGAnalytics *)analytics { - return [[SEGAdjustIntegration alloc] initWithSettings:settings withAnalytics:analytics]; + return [[SEGAdjustIntegration alloc] initWithAppSecret: appSecret settings:settings analytics:analytics]; } - (NSString *)key