Skip to content

Commit

Permalink
fix: add sync for device ID
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori committed Apr 3, 2024
1 parent cf0151d commit 2e30d1c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Sources/Amplitude/Amplitude.m
Original file line number Diff line number Diff line change
Expand Up @@ -1681,11 +1681,13 @@ - (long long)getSessionId {
}

- (NSString *)initializeDeviceId {
if (self.deviceId == nil) {
self.deviceId = [self.dbHelper getValue:DEVICE_ID];
if (![self isValidDeviceId:self.deviceId]) {
self.deviceId = [self _getDeviceId];
[self.dbHelper insertOrReplaceKeyValue:DEVICE_ID value:self.deviceId];
@synchronized (self) {
if (self.deviceId == nil) {
self.deviceId = [self.dbHelper getValue:DEVICE_ID];
if (![self isValidDeviceId:self.deviceId]) {
self.deviceId = [self _getDeviceId];
[self.dbHelper insertOrReplaceKeyValue:DEVICE_ID value:self.deviceId];
}
}
}
return self.deviceId;
Expand Down

0 comments on commit 2e30d1c

Please sign in to comment.