Skip to content

Commit

Permalink
Updated with putDeviceToken method for deviceToken support
Browse files Browse the repository at this point in the history
  • Loading branch information
arnabp92 committed Apr 3, 2020
1 parent 5f8d463 commit 0693cc4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Example/Rudder/_AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#import "_AppDelegate.h"
#import <Rudder/Rudder.h>

static NSString *DATA_PLANE_URL = @"https://89aef425.ngrok.io";
static NSString *DATA_PLANE_URL = @"https://f1bc4b69.ngrok.io";
static NSString *CONTROL_PLANE_URL = @"https://api.rudderlabs.com";
static NSString *WRITE_KEY = @"1Xk22tE75wUqDqCSFvFHqeiYCdT";

@implementation _AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
Expand All @@ -26,6 +25,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[builder withTrackLifecycleEvens:YES];
[builder withRecordScreenViews:YES];
[RudderClient getInstance:WRITE_KEY config:[builder build]];

[[[RudderClient sharedInstance] getContext] putDeviceToken:@"example_device_token"];

return YES;
}

Expand Down
1 change: 1 addition & 0 deletions Rudder/Classes/RudderContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void) updateTraits: (RudderTraits* _Nullable) traits;
- (void) persistTraits;
- (void) updateTraitsDict: (NSMutableDictionary<NSString*, NSObject*>*) traitsDict;
- (void) putDeviceToken: (NSString*) deviceToken;

@end

Expand Down
4 changes: 4 additions & 0 deletions Rudder/Classes/RudderContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ - (void)updateTraitsDict:(NSMutableDictionary<NSString *, NSObject *> *)traitsDi
_traits = traitsDict;
}

- (void)putDeviceToken:(NSString *)deviceToken {
_device.token = deviceToken;
}

- (NSDictionary<NSString *,NSObject *> *)dict {
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
[tempDict setObject:[_app dict] forKey:@"app"];
Expand Down
1 change: 1 addition & 0 deletions Rudder/Classes/RudderDeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readwrite) NSString* model;
@property (nonatomic, readwrite) NSString* name;
@property (nonatomic, readwrite) NSString* type;
@property (nonatomic, readwrite) NSString* token;

@end

Expand Down
3 changes: 3 additions & 0 deletions Rudder/Classes/RudderDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ - (instancetype)init
[tempDict setValue:_model forKey:@"model"];
[tempDict setValue:_name forKey:@"name"];
[tempDict setValue:_type forKey:@"type"];
if (_token != nil) {
[tempDict setValue:_token forKey:@"token"];
}

return [tempDict copy];
}
Expand Down

0 comments on commit 0693cc4

Please sign in to comment.