Skip to content

Commit a200db0

Browse files
authored
fix: assign deviceId correctly on new device (#492)
1 parent 7960a7e commit a200db0

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
48

59
jobs:
610
test:
@@ -32,9 +36,6 @@ jobs:
3236
bundle install
3337
pod install
3438
35-
- name: Validate Podfile
36-
run: pod lib lint
37-
3839
- name: iOS Tests
3940
run: |
4041
xcodebuild test \

Sources/Amplitude/Amplitude.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ - (void)initializeDeviceInfo {
16861686
if (self.deviceId == nil) {
16871687
self.deviceId = [self.dbHelper getValue:DEVICE_ID];
16881688
if (![self isValidDeviceId:self.deviceId]) {
1689-
self.deviceId = [self _getDeviceId];
1689+
self->_deviceId = [self _getDeviceId];
16901690
[self.dbHelper insertOrReplaceKeyValue:DEVICE_ID value:self.deviceId];
16911691
}
16921692
}

Tests/AmplitudeTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,9 +1708,9 @@ - (void)testOpenURLFiresDeepLinkEvent {
17081708
- (void)testGetDeviceIdBeforeInit {
17091709
NSString *instanceName = @"testGetDeviceIdBeforeAndAfterInit";
17101710

1711-
// Clear device ID from db
1711+
// Delete DB before running the test to start fresh
17121712
AMPDatabaseHelper *dbHelper = [AMPDatabaseHelper getDatabaseHelper:instanceName];
1713-
[dbHelper insertOrReplaceKeyValue:@"device_id" value:nil];
1713+
[dbHelper deleteDB];
17141714

17151715
// Device ID should get generated before api key init
17161716
Amplitude *client = [Amplitude instanceWithName:instanceName];

0 commit comments

Comments
 (0)