Device¶
The Capture SDK can be connected to bd tail session through the use of a Device Identifier or Device Code.
Identifier¶
The device identifier can be obtained using the device identifier property on the Capture Logger. The identifier remains consistent as long as the host application is not reinstalled.
It can be used with the deviceid operator in the bd tail CLI command to stream logs directly from the device in real-time.
Kotlin
Logger.deviceId
Java
Logger.getDeviceId()
Swift
Logger.deviceID
Objective-C
[CAPLogger deviceID]
JavaScript
import { getDeviceId } from '@bitdrift/react-native';
getDeviceId().then((deviceId) => {
// Use deviceId
}).catch((error) => {
// Handle error
});
Code¶
Calling Logger.createTemporaryDeviceCode will asynchronously return a device code that's valid for a limited duration of time (around a day).
It can be used with the devicecode operator in the bd tail CLI command to stream logs directly from the device in real-time.
Kotlin
import com.github.michaelbull.result.onFailure
import com.github.michaelbull.result.onSuccess
import io.bitdrift.capture.Capture.Logger
// Result uses https://github.com/michaelbull/kotlin-result
Logger.createTemporaryDeviceCode(completion = { result ->
result.onSuccess { deviceCode ->
// Display code
}
result.onFailure { error ->
// Handle error
}
})
Java
import com.github.michaelbull.result.OnKt;
import io.bitdrift.capture.Capture.Logger;
// Result uses https://github.com/michaelbull/kotlin-result
Logger.createTemporaryDeviceCode(result -> {
OnKt.onSuccess(result, deviceCode -> {
// Display code
return null;
});
OnKt.onFailure(result, error -> {
// Handle error
return null;
});
return null;
});
Swift
Logger.createTemporaryDeviceCode { result in
switch result {
case .success(let deviceCode):
// Display code
case .failure(let error):
// Handle error
}
}
JavaScript
import { generateDeviceCode } from '@bitdrift/react-native';
generateDeviceCode().then((deviceCode) => {
// Display code
}).catch((error) => {
// Handle error
});