Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App secret #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Pod/Classes/SEGAdjustAppSecret.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import <Foundation/Foundation.h>


@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
34 changes: 34 additions & 0 deletions Pod/Classes/SEGAdjustAppSecret.m
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Pod/Classes/SEGAdjustIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSNumber *> *)secret settings:(NSDictionary *)settings analytics:(SEGAnalytics *)analytics;

@end
24 changes: 23 additions & 1 deletion Pod/Classes/SEGAdjustIntegration.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#import "SEGAdjustIntegration.h"
#import "SEGAdjustAppSecret.h"
#import <Analytics/SEGAnalyticsUtils.h>

@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;
Expand All @@ -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];
}
Expand Down
3 changes: 3 additions & 0 deletions Pod/Classes/SEGAdjustIntegrationFactory.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#import <Foundation/Foundation.h>
#import <Analytics/SEGIntegrationFactory.h>

@class SEGAdjustAppSecret;


@interface SEGAdjustIntegrationFactory : NSObject <SEGIntegrationFactory>

+ (instancetype)instance;
+ (instancetype)instanceWithAppSecret:(nullable SEGAdjustAppSecret *)secret NS_SWIFT_NAME(instance(appSecret:));

@end
18 changes: 13 additions & 5 deletions Pod/Classes/SEGAdjustIntegrationFactory.m
Original file line number Diff line number Diff line change
@@ -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<SEGIntegration>)createWithSettings:(NSDictionary *)settings forAnalytics:(SEGAnalytics *)analytics
{
return [[SEGAdjustIntegration alloc] initWithSettings:settings withAnalytics:analytics];
return [[SEGAdjustIntegration alloc] initWithAppSecret: appSecret settings:settings analytics:analytics];
}

- (NSString *)key
Expand Down