Class BitwardsService
BitwardsService — SDK Usage Guide
Contents
- Introduction
- User Experience (UX) Considerations
- Error and Reason Code Reference
- Initialize SDK
- Login End User
- Setup Callback for NFC Based Resources
- Synchronize with Backend Server
- Get Known Resource List
- Register/Unregister for Discovering Resources Nearby
- Access a Resource
- Discover and Access a Selected Resource
- Logout End User
- Utility Functions
Introduction
BitwardsService is the main entry point of Bitwards SDK. All SDK operations
are performed through this class. The main areas of functionality are:
- initializing the SDK and logging the end user in and out,
- synchronizing the local credential database with the backend server,
- scanning for nearby Bluetooth Low Energy (BLE) based resources,
- accessing resources via BLE or NFC, and
- retrieving the resource list and user profile data.
The following sections describe each of these areas with code examples.
Most SDK operations are asynchronous: an operation is triggered by a method call and its result is delivered through a callback. All SDK methods should be called from the main (UI) thread; all callbacks are also executed on the main thread.
NOTE: All documentation assumes that the developer is familiar with Android development. For project setup instructions (Gradle dependency, manifest configuration, permissions), see the package overview.
User Experience (UX) Considerations
Bitwards SDK supports several access interaction patterns for BLE-based resources.
The right pattern depends on the use case and the desired end-user experience.
All patterns rely on the Bluetooth signal strength (RSSI) reported by
BitwardsResource.getRSSI(). Note that RSSI is an inherently noisy measurement:
it varies with phone model, resource hardware, resource configuration, and the
surrounding physical environment (walls, furniture, other devices). This variability
must be taken into account when designing RSSI-based UX.
Manual Opening
In this pattern the application runs the background scan continuously and presents
the end user with a list of resources. The list may show all known resources, or it
may be filtered to show only the resources currently in Bluetooth range. Each list
item should display the resource name (so the end user can identify the correct one)
and a visual indicator of signal strength (so nearby resources are easy to spot).
Because BitwardsService.BackgroundScanCallback.onResourceFound(BitwardsResource) is called approximately every 500 ms per nearby
resource, the signal-strength indicator can be updated in real time, giving the end
user a live sense of proximity.
When the end user taps a resource, the application calls
accessResource(BitwardsResource, BLEResourceCallback) for that resource.
The UI should immediately show a progress state (e.g., "Accessing…") while the BLE
communication is in progress. Once the callback fires, the UI should update to reflect
the outcome:
- Access granted — show a clear success indicator (e.g., a green checkmark or "Access granted" message).
- Access denied — inform the end user that access was not permitted, and include a reason where available (e.g., "Outside of allowed hours").
- Error — inform the end user that the attempt failed and allow them to retry. Transient BLE errors are common; a single retry is usually sufficient.
Automatic Opening
Automatic opening removes the need for the end user to tap a resource explicitly. The application runs the background scan and monitors the RSSI of each nearby resource. When the RSSI of a resource crosses a configured threshold — meaning the phone has been brought physically close to the resource — the application initiates the access attempt automatically. This closely resembles the UX of NFC-based access, where the end user simply holds the phone near the reader to trigger opening.
The main challenge of this pattern is choosing an appropriate RSSI threshold. Because RSSI is affected by phone hardware, resource hardware, resource firmware configuration, and environmental factors (walls, metal surfaces, interference), a single universal threshold is unlikely to work well across all deployments. In practice, the threshold often needs to be tuned at least per resource type, and in some cases per phone model. The following considerations help in setting a workable threshold:
- Start with a conservative (strong signal) threshold, e.g., −55 dBm, and adjust based on real-world testing in the target environment.
- Apply hysteresis: require the signal to remain above the threshold for a short time (e.g., 1–2 seconds) before triggering, to avoid false positives caused by momentary spikes.
- Ensure only one access attempt is triggered per approach: once an attempt has been started for a resource, ignore further threshold crossings for that resource until the attempt completes and the signal drops below the threshold again.
- Show status and result feedback the same way as in the Manual Opening pattern.
Discover and Access Resource
discoverAndAccessResource(BLEResourceCallback) provides a self-contained
scan-then-access flow without requiring a continuously running background scan. The
SDK performs an internal BLE scan for a few seconds, collects all nearby known
resources, and returns them sorted by signal strength (strongest first) via the
onSelectResource() callback. The application then picks the resource to open
and signals its selection back to the SDK via BitwardsService.SelectResourceCallback.
The most natural UX for this pattern is a single prominent button such as "Open nearest door". When the end user taps the button:
- The application shows a scanning indicator (e.g., "Looking for nearby resources…").
- Once resources are discovered, the application either automatically selects the closest one (first in the list) or presents a brief selection dialog if multiple resources are found.
- The SDK attempts to open the selected resource and reports the outcome via the same callback, which the application reflects in the UI as described in Manual Opening.
Error and Reason Code Reference
Most BitwardsService operations report failures by delivering an integer error
code to the relevant callback's onError(int) method, or by throwing a
BitwardsException whose error code can be retrieved via
BitwardsException.getErrorCode(). Access denials from the physical reader
are reported as integer reason codes via
BitwardsService.NFCResourceCallback.onAccessDenied(BitwardsResource, int).
There are many error and reason codes, each covering a specific failure condition. They are fully documented — with descriptions, commonality ratings, and emission sources — in the separate Error and Reason Code Reference.
Initialize SDK
Bitwards SDK is initialized by calling getInstance(Context, String), which returns
a singleton BitwardsService instance — the same instance is returned on every call.
IMPORTANT: The required permissions must be granted by the end user before
calling getInstance(Context, String). If the permissions have not been granted,
the call will throw a BitwardsException and the SDK cannot be used.
The required permissions depend on the Android version:
- Android 11 or older (SDK 30 or lower): ACCESS_FINE_LOCATION must be granted. See Request location permissions for details.
- Android 12 or newer (SDK 31 or higher): BLUETOOTH_SCAN and BLUETOOTH_CONNECT must be granted. If the application does not use ACCESS_FINE_LOCATION, the BLUETOOTH_SCAN declaration in the manifest must include android:usesPermissionFlags="neverForLocation", otherwise Bluetooth scanning will not work. See Bluetooth permissions for details.
It is recommended to check for the required permissions each time the application starts, as Android may revoke permissions that have not been used for an extended period.
Note: Bitwards SDK no longer requires device lock to be enabled.
String license = "contains license that is obtained from Bitwards (currently not used)";
// Get the BitwardsService singleton instance:
BitwardsService bws = BitwardsService.getInstance(context.getApplicationContext(), license);
Login end user
A BitwardsService instance is not usable until an end user has logged in. Login can be performed either with a username and password, or with an OAuth2 authentication token, if the server configuration allows it.
// Create credential with username and password (if username/password is used)
BitwardsCredential passwordCredential = new BitwardsCredential.Builder(BitwardsCredential.TYPE_USERNAME_PASSWORD)
.setUsername(USERNAME)
.setPassword(PASSWORD)
.build();
// Create credential with OAuth2 (if OAuth2 token is used)
BitwardsCredential oauth2token = new BitwardsCredential.Builder(BitwardsCredential.TYPE_OAUTH2_AUTH_TOKEN)
.setAuthenticationToken(AUTH_TOKEN)
.setAuthenticationDomain(AUTH_DOMAIN)
.build();
// Create credential with OAuth2 (if OAuth2 authorization_code is used)
BitwardsCredential oauth2authorizationCode = new BitwardsCredential.Builder(BitwardsCredential.TYPE_OAUTH2_AUTH_TOKEN)
.setAuthenticationToken(AUTHORIZATION_CODE)
.setAuthenticationDomain(AUTH_DOMAIN)
.setGrantType("authorization_code")
.setRedirectUrl(REDIRECT_URL)
.build();
// Login with credential (this time OAuth2)
bws.login(oauth2token, new BitwardsService.ResultCallback() {
@Override
public void onSuccess() {
// Login was successful
}
@Override
public void onError(int errorCode) {
// Login failed
}
});
// Register a callback to be notified when the session expires (user is logged out):
bws.setAuthenticationTokenExpiredCallback((bitwardsService) -> {
// Handle session expiry (e.g., notify the user that they have
// been logged out and navigate to the login screen).
});
Setup callback for NFC based resources
Bitwards SDK can access resources via NFC. NFC-based opening happens automatically,
but if the application wants to receive notifications for these events,
it must register a BitwardsService.NFCResourceCallback.
If resource opening with NFC based resource access is required to be supported when application is not running or when it is in the background, the FOREGROUND_SERVICE_CONNECTED_DEVICE permission needs to be declared in Android 14 and later. See Foreground service types and espacially Connected Device section in particular for details.
NOTE: If NFC based resources needs to be supported, a nfcservice.xml file needs to be placed to the res/xml directory in the module in your application project. Please request the nfcservice.xml file from Bitwards.
// Setup callback for NFC based resources
bws.setNFCResourceCallback(new BitwardsService.NFCResourceCallback() {
@Override
public void onAccessGranted(BitwardsResource resource) {
// Access to a NFC based resource was granted
}
@Override
public void onAccessDenied(BitwardsResource resource, int reasonCode) {
// Access to a NFC based resource was denied
}
@Override
public void onError(BitwardsResource resource, int errorCode) {
// An error occurred when accessing a NFC based resource
}
});
Synchronize with backend server
Bitwards SDK synchronizes with the backend server automatically once an hour.
If the application needs to ensure that the data (e.g., the known resource list)
is immediately up to date, call synchronize(ResultCallback) manually.
// Synchronize Bitwards SDK's database with the backend server
bws.synchronize(new BitwardsService.ResultCallback() {
@Override
public void onSuccess() {
// Synchronization with the backend server was successful
}
@Override
public void onError(int errorCode) {
// Synchronization failed
}
});
Get known resource list
The known resource list is the list of resources that the end user
either has access currently, or will have access in the future.
Each BitwardsResource in the list can be passed to
accessResource(BitwardsResource, BLEResourceCallback) to access the resource (e.g., open it).
// Obtain the known resource list
List<BitwardsResource> list = bws.getBitwardsResourceList();
Register/unregister for discovering resources nearby
The background scan discovers nearby Bluetooth-based resources (BLE resources).
When a BitwardsService.BackgroundScanCallback instance is registered with the Bitwards SDK,
its callback methods notify the application that a resource has come into range or
has been lost (i.e., is no longer nearby).
BitwardsService.BackgroundScanCallback.onResourceFound(BitwardsResource) is called approximately
every 500 ms per resource while it is in Bluetooth range.
The application can obtain the current signal strength using BitwardsResource.getRSSI(),
which returns an RSSI (received signal strength indicator) estimate based on Bluetooth
advertisement messages received over the past 10 seconds.
If no advertisement messages have been received, the RSSI value gradually decreases to −99,
after which BitwardsService.BackgroundScanCallback.onResourceLost(BitwardsResource) is called.
This smoothing logic prevents the value from fluctuating too much and accounts for the fact
that battery-powered resources may not transmit advertisement messages as frequently as
mains-powered ones. The smoothed RSSI value can therefore be used directly in the
application UI to display signal strength.
// Instantiate BackgroundScanCallback instance
BitwardsService.BackgroundScanCallback callback = new BitwardsService.BackgroundScanCallback() {
@Override
public void onResourceFound(BitwardsResource resource) {
// called each time a resource is detected; approximately every 500 ms per nearby resource
// Obtain the Bluetooth signal strength (RSSI):
int rssi = resource.getRSSI();
// rssi value is typically between −30 and −99, where
// −30 means signal is strong (resource is very close), and
// −70 means signal is weak (resource is farther away).
}
@Override
public void onResourceLost(BitwardsResource resource) {
// a previously found resource is no longer nearby
}
@Override
public void onError(int errorCode) {
// an error occurred during background scan; scan is stopped
}
};
// Register callback with BitwardsService for background scan callbacks
bws.registerBackgroundScanCallback(callback);
// Unregister callback when you are done with background scan callbacks
bws.unregisterBackgroundScanCallback(callback);
Access a resource
To access a resource (e.g., opening it) call accessResource(BitwardsResource, BLEResourceCallback).
Best practice is that the application first discovers nearby resources
with the background scan callback, and then populates a list of available resources
in the application UI. The end user then taps one of the available resources, which
triggers calling of accessResource(BitwardsResource, BLEResourceCallback) with
the indicated BitwardsResource instance.
// Accessing (e.g., opening) a particular resource
bws.accessResource(resource, new BitwardsService.BLEResourceCallback() {
@Override
public void onSelectResource(List<BitwardsResource> resources, BitwardsService.SelectResourceCallback callback) {
// In this case (i.e., resource was already indicated in the method call),
// this is not gonna be called because we are accessing directly the particular resource.
}
@Override
public void onResourceNotFound(BitwardsResource resource) {
// The BLE based resource was not found, i.e., it is not nearby.
}
@Override
public void onAccessGranted(BitwardsResource resource) {
// Access was granted to the BLE based resource.
}
@Override
public void onAccessDenied(BitwardsResource resource, int reasonCode) {
// Access was denied to the BLE based resource.
}
@Override
public void onError(BitwardsResource resource, int errorCode) {
// An error occurred while accessing the BLE based resource.
// This happens sometimes. Application can indicate the error
// in the UI, and the end user can try to access the resource again.
}
});
Discover and access a selected resource
discoverAndAccessResource(BLEResourceCallback) is one method call that does
both the discovery (scans of known resources) as well as access a resource that was
selected. Essentially, this is the same as using the background scan callback combined
with accessing a discovered resource. First a two-and-a-half second Bluetooth scan is performed.
Second, a list of discovered known resources are returned via the
onSelectResource() callback.
Third, a resource can be selected to be accessed and it is indicated with the
BitwardsService.SelectResourceCallback interface. Finally, the selected resource is accessed.
// First scan for any nearby known resources and then select the resource to be accessed:
bws.discoverAndAccessResource(new BitwardsService.BLEResourceCallback() {
@Override
public void onSelectResource(List<BitwardsResource> resources, BitwardsService.SelectResourceCallback callback) {
// Select among the discovered BLE based resources which one to open,
// resource with strongest bluetooth signal is first in the list
// As an example, we are going to select the resource with
// strongest bluetooth signal (i.e., first resource on the list)
callback.selectedResource(resources.get(0));
}
@Override
public void onResourceNotFound(BitwardsResource resource) {
// No resources were found during the scan phase.
}
@Override
public void onAccessGranted(BitwardsResource resource) {
// Access was granted for the selected resource
}
@Override
public void onAccessDenied(BitwardsResource resource, int reasonCode) {
// Access was denied for the selected resource
}
@Override
public void onError(BitwardsResource resource, int errorCode) {
// An error occurred while accessing the selected resource.
}
});
Logout end user
BitwardsService instance can be logged out from the backend server at anytime.
After this, resources cannot be accessed anymore. login(BitwardsCredential, ResultCallback)
must be called again in order to perform operations with resources.
// Logout from backend server
bws.logout(new BitwardsService.ResultCallback() {
@Override
public void onSuccess() {
// Logout with the backend server was successful
}
@Override
public void onError(int errorCode) {
// Logout failed
}
});
Utility functions
Enable error reporting
Bitwards SDK is capable of reporting errors back to Bitwards servers, but this needs to be enabled when the application launches. Bitwards SDK uses its own error and crash reporting. When a crash occurs and error reporting is enabled, a notification is shown to the end user.
In order to send error reports, the following configuration parameters need to be added to module's build.gradle file:
android {
...
defaultConfig {
...
// The URL where the error reports are sent (mandatory):
manifestPlaceholders.bitwardsErrorReportUri = "<ERROR_REPORT_URL>"
// If there is a need to add extra HTTP header for authorization, it can be
// as described below. ERROR_REPORT_HEADER should be in "<HEADER_NAME>: <HEADER_VALUE>" format.
// Example: "X-Key: putHereTheSecretKey".
manifestPlaceholders.bitwardsErrorReportHeader = "<ERROR_REPORT_HEADER>"
}
...
}
Error reporting is enabled during application runtime the following way:
// Enable error reporting:
BitwardsService.Debug.setErrorReporting(true);
Application can also configure Bitwards SDK to do deeper diagnostics, which means Bitwards SDK sends error reports more frequently. The diagnostics is enabled the following way:
bws.setBitwardsConfig(new BitwardsConfig.Builder()
.setBoolean(BitwardsConfig.DIAGNOSTICS_ENABLED, true)
.setOverWrite(true)
.build());
Error code to error string
Bitwards SDK has a lot of error codes. In order to get the textual representation for debugging purposes (and printed to logcat, for instance), the developer can use the following.
// The error code returned by Bitwards SDK (example)
int errorCode = 0;
// The human-readable string representing the error code
String errorText = BitwardsService.Debug.getErrorString(errorCode);
// See the error code constants defined in BitwardsService for possible values
Getting error code from BitwardsException
The Bitwards error code can be obtained from Bitwards exception as follows:
try {
...
} catch (BitwardsException be) {
int errorCode = be.getErrorCode();
// process the error code
}-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAuthenticationTokenExpiredCallback is used to notify UI that authentication token has expired.static interfaceBackground BLE scan callback for reporting found/lost resources.static interfaceCallback to deliver Installation request list or error of the operation.static interfaceDeprecated.static interfaceBitwardsResourceListUpdatedCallback is used to notify UI that BitwardsResource list has been updated from the server.static interfaceCallback to deliver Bitwards resource type list or error of the operation.static interfaceCallback to deliver Bitwards end user's profile data or error of the operation.static interfaceResource callback notifications when connecting and communicating with a resource using BLE.static interfaceBLEResourceConnectionStateCallback can be used instead of basic BLEResourceCallback interface.static interfaceResource callback notifications when the application also wants a callback when the resource maintenance phase during the communication has been completed.static classBluetoothProximityAccess class is used to handle Bluetooth proximity access functionality.static final classThis inner class is used configure Bitwards SDK further.static final classBitwardsService.Debug class is used to setup error reporting.static classLoginCallback can be used instead of ResultCallback when usinglogin(BitwardsCredential, ResultCallback)method.static interfaceResource callback notifications when connecting and communicating with a resource using NFC.static interfacestatic interfaceCallback to notify success or error of an operation.static interfaceSelect resource callback is used when more than one known resources were found. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe logged in end user does not have the permission to access the requested service.static final intThe application does not have the BLUETOOTH_CONNECT permission.static final intBitwardsService instance is already initialized.static final intBitwards end user is already logged in, BitwardsService instance is already connected to Bitwards backend environment.static final intAnother operation is already ongoing.static final intAuthentication token with the server has expired, sign in again needed.static final intBackground scan was stopped manually.static final intBitwards resource error: Bluetooth MAC address was invalid.static final intBitwards resource error: Resource is malfunctioning.static final intAn Bluetooth operation already active.static final intBitwards resource error: Accessed bluetooth device is not a resource.static final intBitward resource error: Bluetooth scan is already active.static final intBitwards resource error: Bluetooth scan failed.static final intBluetooth scan is not active.static final intBitwards resource error: Application does not have permission to use Bluetooth (needs access to permission).static final intDevice does not support Bluetooth.static final intBitwards resource error: Bluetooth is not on in the device.static final intBitwards resource error: Bluetooth was disabled during operation.static final intCallback is null.static final intCancel Bitwards resource reservation server communication error.static final intPassword change of the logged in Bitwards end user failed.static final intChanging the profile of the logged in Bitwards end user failed.static final intBitwards resource error: Bluetooth connection is already active.static final intDevice error: device not able to send long RAPDU message to the resource due to malfunctioning BLE in the device.static final intBitwards resource error: Bluetooth GATT error occurred (try again).static final intBitwards resource error: GATT characteristic read failure.static final intGet location list server communication error.static final intGet the Bitwards resource list of the logged in Bitwards end user failed.static final intGetting the profile of the logged in Bitwards end user failed.static final intInitialization of BitwardsService instance failed.static final intInstallation is active.static final intInstallation failed.static final intInstallation is not active.static final intInstallation task was cancelledstatic final intInstallation task is not in pending mode (it has been already performed)static final intTesting access to the installed Bitwards resource failed, but installation was otherwise carried out successfully.static final intAndroid device's Location service is disabled.static final intLogin of the Bitwards end user to the Bitwards backend environment failed.static final intLogin failed because user does not exist.static final intLogin failed due to server error.static final intLogout of the logged in Bitwards end user from the Bitwards backend environment failed.static final intBitwards resource error: Application does not have NFC permission.static final intDevice does not support NFC.static final intThe application does not have the BLUETOOTH_CONNECT permission.static final intThe application does not have the BLUETOOTH_SCAN permission.static final intDevice is not connected to internet.static final intApplication does not have location permission (ACCESS_FINE_LOCATION).static final intApplication does not have NFC permission.static final intApplication does not have READ_DEVICE_STATE permissionstatic final intBitwardsService instance is not connected.static final intBitwardsService instance is not initialized.static final intBitwards end user is not logged in, BitwardsService instanced is not connected to Bitwards backend environment.static final intRefresh connection to server failed.static final intLogout reason: The refresh of the authentication token with OAuth2 failed because end user needs to re-login.static final intInstallation failed because the resoruce was already installed.static final intBitwards resource error: resource disconnected.static final intBitwardsResource instance is nullstatic final intBitwards resource error: resource was moved out of range.static final intOperation with Bitwards resource failed: application does not support the protocol resource is using, application update is required.static final intBitwards resource reservation server communication error.static final intBitwards resource error: connection to resource timed out.static final intBitwards resource error: unknown error occurred.static final intAnother Bitwards resource update process is active.static final intUpdate process of the Bitwards resource failed.static final intBitwards resource update process is not active.static final intBitwards resource update task was cancelled.static final intDeprecated.static final intCancel Bitwards resource reservation failed response by server.static final intInstallation failed because server failed to new Bitwards resource response by server.static final intGet location list failed response by server.static final intInstallation failed because internal error response by server.static final intInstallation failed because the Bitwards resource was already installed response by server.static final intBitwards resource reservation failed response by server.static final intInstallation failed because serial number already exists response by server.static final intTimeout occurredstatic final intAn unknown error occurred.static final intUnknown background scan mode.static final intLogout reason: End user logged out.static final intInstallation task to be cancelled was not the active one.static final intWrong Bitwards resource update task was cancelled.static final intOperation with Bitwards resource failed: bad data.static final intOperation with Bitwards resource failed: token creation time in future.static final intOperation with Bitwards resource failed: delegation cache overrun.static final intOperation with Bitwards resource failed: delegation used.static final intOperation with Bitwards resource failed: handle is in wrong positionstatic final intOperation with Bitwards resource failed: token owner has illegal user role.static final intOperation with Bitwards resource failed: application does not have have a valid token for the resource.static final intOperation with Bitwards resource failed: access denied due to exception schedule.static final intOperation with Bitwards resource failed: access denied due to regular schedule access list.static final intOperation with Bitwards resource failed: operation failed due to resource's battery being critical.static final intOperation with Bitwards resource failed: peripheral communication failure occurred.static final intOperation with Bitwards resource failed: peripheral failure occurred.static final intOperation with Bitwards resource failed: resource is already reserved.static final intOperation with Bitwards resource failed: token is blacklisted.static final intOperation with Bitwards resource failed: wrong delegation.static final intOperation with Bitwards resource failed: bad signature.static final intOperation with Bitwards resource failed: token has wrong time window.static final intBluetooth scan mode: scan for Bitwards resources will report all found resources, including unknown ones.static final intBluetooth scan mode: scan for Bitwards resources will report only regular resources known by the logged in Bitwards end user.static final intBluetooth scan mode: scan for Bitwards resources will report only universal resources known by the logged in Bitwards end user. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccessResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) Attempt to connect to and access a Bitwards resource using BLE.voidchangePassword(String oldPassword, String newPassword) Deprecated.voidchangePassword(String oldPassword, String newPassword, BitwardsService.ResultCallback callback) Change password of the logged in Bitwards end user.voidconnect(String url, BitwardsCredential credential, BitwardsService.ResultCallback callback) Deprecated.voidconnect(String url, String username, String password, BitwardsService.ResultCallback callback) Deprecated.voidconnectToResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) Deprecated.voiddeleteUserAccount(List<Long> accountIDs, BitwardsService.ResultCallback callback) todo add documentationvoidDeprecated.voiddisconnect(BitwardsService.ResultCallback callback) Deprecated.voidStart a bluetooth scan for discovering BLE based Bitwards resources that are known to end user.voiddiscoverAndAccessResource(BitwardsService.BLEResourceCallback callback, int mode) Start bluetooth scan for discovering BLE based Bitwards resources.Deprecated.Get the Bitwards admin info list of the logged in Bitwards end user.voidgetBitwardsInstallationRequestList(boolean sync, BitwardsService.BitwardsInstallationRequestListCallback callback) Get the Bitwards resource installation request list of the Bitwards end user.Get the Bitwards resource list of the logged in Bitwards end user.getBitwardsResourceList(boolean sync) Deprecated.voidgetBitwardsResourceList(boolean sync, BitwardsService.BitwardsResourceListCallback callback) Deprecated.voidgetBitwardsResourceTypeList(boolean sync, BitwardsService.BitwardsResourceTypeListCallback callback) Get the resource type list of the Bitwards resources.Get profile properties of the logged in Bitwards end user.voidDeprecated.static BitwardsServiceDeprecated.static BitwardsServicegetInstance(android.content.Context context, String license) Get BitwardsService instance.intGet reason for the most recent logout whenBitwardsService.AuthenticationTokenExpiredCallbackhas been used.Get the version of the BitwardsService instance.voidDeprecated.voidinitialize(BitwardsService.ResultCallback callback) Deprecated.booleanDeprecated.voidCheck if authentication token used with the Bitwards backend environment is valid.booleanCheck if BitwardsService instance has the background bluetooth scan is active.booleanDeprecated.booleanDeprecated.booleanCheck if BitwardsService instance is logged in to Bitwards backend environment.booleanCheck if the processing of NFC connections is paused.booleanCheck if BitwardsService instance has an asynchronous operation active.voidlogin(BitwardsCredential credential, BitwardsService.ResultCallback callback) Login to Bitwards backend environment.voidlogout()Log out from Bitwards backend environment.voidlogout(BitwardsService.ResultCallback callback) Deprecated.voidmaintainResource(BitwardsResource resource, BitwardsService.BLEResourceMaintenanceCallback callback) Attempt to connect to and execute maintenance with a Bitwards resource using BLE.voidpauseNfc()Pause processing of NFC connections from Bitwards resources.voidrefresh(BitwardsCredential credential, BitwardsService.ResultCallback callback) Refresh connection to Bitwards backend environment using new BitwardsCredential.voidRegister a BackgroundScanCallback instance to discover BLE based Bitwards resources that are known to the logged in Bitwards end user.voidregisterBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback, int mode) Register a BackgroundScanCallback instance to discover BLE based Bitwards resources, optionally also unknown Bitwards resources to the logged in Bitwards end user are included.voidResume processing of NFC connections from Bitwards resources.voidscanAndAccessResource(BitwardsResource resource, long scanTime, BitwardsService.BLEResourceCallback callback) Scan for the given resource and if found, access the resource.voidDeprecated.voidscanForResource(BitwardsService.BLEResourceCallback callback, int mode) Deprecated.voidSet callback for receiving notifications when the authentiation token has expired.voidsetBitwardsConfig(BitwardsConfig config) Set default settings for BitwardsService instance.voidsetBitwardsResourceListUpdatedCallback(BitwardsService.BitwardsResourceListUpdatedCallback callback) Set the callback for receiving notifications when the list of Bitwards resources for the logged in Bitwards end user has been updated automatically.voidSet the callback for NFC based Bitwards resource event callbacks.voidsetNotifier(Class clazz) Set BitwardsService.Notifier class.voidDeprecated.voidstartBackgroundScan(BitwardsService.BackgroundScanCallback callback, int mode) Deprecated.voidStart Bitwards resource discovery for proximity access.voidStop the ongoing BLE background scan.voidStop Bitwards resource discovery for proximity access.voidsynchronize(BitwardsService.ResultCallback callback) Synchronize the local SDK database (e.g., Bitwards resource list and user data) with the Bitwards backend server.voidUnregister a BackgroundScanCallback instance.Deprecated.voidupdateBitwardsUser(BitwardsUser user, BitwardsService.BitwardsUserCallback callback) Change profile data of the logged in Bitwards end user.
-
Field Details
-
RESOURCE_SCAN_MODE_FULL
public static final int RESOURCE_SCAN_MODE_FULLBluetooth scan mode: scan for Bitwards resources will report all found resources, including unknown ones.- See Also:
-
RESOURCE_SCAN_MODE_KNOWN
public static final int RESOURCE_SCAN_MODE_KNOWNBluetooth scan mode: scan for Bitwards resources will report only regular resources known by the logged in Bitwards end user.- See Also:
-
RESOURCE_SCAN_MODE_UNIVERSAL
public static final int RESOURCE_SCAN_MODE_UNIVERSALBluetooth scan mode: scan for Bitwards resources will report only universal resources known by the logged in Bitwards end user.- See Also:
-
ERROR_BLUETOOTH_NO_PERMISSION
public static final int ERROR_BLUETOOTH_NO_PERMISSIONBitwards resource error: Application does not have permission to use Bluetooth (needs access to permission).- See Also:
-
ERROR_BLUETOOTH_NOT_ENABLED
public static final int ERROR_BLUETOOTH_NOT_ENABLEDBitwards resource error: Bluetooth is not on in the device.- See Also:
-
ERROR_BLE_SCAN_FAILED
public static final int ERROR_BLE_SCAN_FAILEDBitwards resource error: Bluetooth scan failed.- See Also:
-
ERROR_BAD_RESOURCE
public static final int ERROR_BAD_RESOURCEBitwards resource error: Resource is malfunctioning.- See Also:
-
ERROR_GATT_ERROR
public static final int ERROR_GATT_ERRORBitwards resource error: Bluetooth GATT error occurred (try again).- See Also:
-
ERROR_DEVICE_CONNECTION_ACTIVE
public static final int ERROR_DEVICE_CONNECTION_ACTIVEBitwards resource error: Bluetooth connection is already active.- See Also:
-
ERROR_BLE_SCAN_ALREADY_ACTIVE
public static final int ERROR_BLE_SCAN_ALREADY_ACTIVEBitward resource error: Bluetooth scan is already active.- See Also:
-
ERROR_BLE_NOT_RESOURCE
public static final int ERROR_BLE_NOT_RESOURCEBitwards resource error: Accessed bluetooth device is not a resource.- See Also:
-
ERROR_NFC_NO_PERMISSION
public static final int ERROR_NFC_NO_PERMISSIONBitwards resource error: Application does not have NFC permission.- See Also:
-
ERROR_BLUETOOTH_WAS_DISABLED
public static final int ERROR_BLUETOOTH_WAS_DISABLEDBitwards resource error: Bluetooth was disabled during operation.- See Also:
-
ERROR_BAD_MAC_ADDRESS
public static final int ERROR_BAD_MAC_ADDRESSBitwards resource error: Bluetooth MAC address was invalid.- See Also:
-
ERROR_RESOURCE_OUT_OF_RANGE
public static final int ERROR_RESOURCE_OUT_OF_RANGEBitwards resource error: resource was moved out of range.- See Also:
-
ERROR_RESOURCE_DISCONNECTED
public static final int ERROR_RESOURCE_DISCONNECTEDBitwards resource error: resource disconnected.- See Also:
-
ERROR_RESOURCE_TIMEOUT
public static final int ERROR_RESOURCE_TIMEOUTBitwards resource error: connection to resource timed out.- See Also:
-
ERROR_GATT_READ_FAILURE
public static final int ERROR_GATT_READ_FAILUREBitwards resource error: GATT characteristic read failure. This error should be treated as ERROR_BAD_RESOURCE.)- See Also:
-
ERROR_FAILED_TO_SEND_LONG_RAPDU
public static final int ERROR_FAILED_TO_SEND_LONG_RAPDUDevice error: device not able to send long RAPDU message to the resource due to malfunctioning BLE in the device. Unfortunately, this error typically means that the App cannot access the resource in this device.- See Also:
-
ERROR_RESOURCE_UNKNOWN_ERROR
public static final int ERROR_RESOURCE_UNKNOWN_ERRORBitwards resource error: unknown error occurred.- See Also:
-
ERROR_UNKNOWN
public static final int ERROR_UNKNOWNAn unknown error occurred.- See Also:
-
ERROR_NO_INTERNET
public static final int ERROR_NO_INTERNETDevice is not connected to internet.- See Also:
-
ERROR_NOT_LOGGED_IN
public static final int ERROR_NOT_LOGGED_INBitwards end user is not logged in, BitwardsService instanced is not connected to Bitwards backend environment.- See Also:
-
ERROR_ALREADY_LOGGED_IN
public static final int ERROR_ALREADY_LOGGED_INBitwards end user is already logged in, BitwardsService instance is already connected to Bitwards backend environment.- See Also:
-
ERROR_LOGIN_FAILED
public static final int ERROR_LOGIN_FAILEDLogin of the Bitwards end user to the Bitwards backend environment failed.- See Also:
-
ERROR_LOGOUT_FAILED
public static final int ERROR_LOGOUT_FAILEDLogout of the logged in Bitwards end user from the Bitwards backend environment failed.- See Also:
-
ERROR_CHANGE_PASSWORD_FAILED
public static final int ERROR_CHANGE_PASSWORD_FAILEDPassword change of the logged in Bitwards end user failed.- See Also:
-
ERROR_GET_USER_PROFILE_FAILED
public static final int ERROR_GET_USER_PROFILE_FAILEDGetting the profile of the logged in Bitwards end user failed.- See Also:
-
ERROR_CHANGE_USER_PROFILE_FAILED
public static final int ERROR_CHANGE_USER_PROFILE_FAILEDChanging the profile of the logged in Bitwards end user failed.- See Also:
-
ERROR_GET_RESOURCE_LIST_FAILED
public static final int ERROR_GET_RESOURCE_LIST_FAILEDGet the Bitwards resource list of the logged in Bitwards end user failed.- See Also:
-
ERROR_INITIALIZATION_FAILED
public static final int ERROR_INITIALIZATION_FAILEDInitialization of BitwardsService instance failed.- See Also:
-
ERROR_NOT_INITIALIZED
public static final int ERROR_NOT_INITIALIZEDBitwardsService instance is not initialized.- See Also:
-
ERROR_ALREADY_INITIALIZED
public static final int ERROR_ALREADY_INITIALIZEDBitwardsService instance is already initialized.- See Also:
-
ERROR_NOT_CONNECTED
public static final int ERROR_NOT_CONNECTEDBitwardsService instance is not connected.- See Also:
-
ERROR_BLE_ALREADY_ACTIVE
public static final int ERROR_BLE_ALREADY_ACTIVEAn Bluetooth operation already active.- See Also:
-
ERROR_LOGIN_FAILED_DUE_TO_SERVER_ERROR
public static final int ERROR_LOGIN_FAILED_DUE_TO_SERVER_ERRORLogin failed due to server error.- See Also:
-
ERROR_CALLBACK_NULL
public static final int ERROR_CALLBACK_NULLCallback is null.- See Also:
-
ERROR_NO_LOCATION_PERMISSION
public static final int ERROR_NO_LOCATION_PERMISSIONApplication does not have location permission (ACCESS_FINE_LOCATION).- See Also:
-
ERROR_NO_NFC_PERMISSION
public static final int ERROR_NO_NFC_PERMISSIONApplication does not have NFC permission.- See Also:
-
ERROR_NO_READ_DEVICE_STATE_PERMISSION
public static final int ERROR_NO_READ_DEVICE_STATE_PERMISSIONApplication does not have READ_DEVICE_STATE permission- See Also:
-
ERROR_BLUETOOTH_NOT_AVAILABLE
public static final int ERROR_BLUETOOTH_NOT_AVAILABLEDevice does not support Bluetooth.- See Also:
-
ERROR_NFC_NOT_AVAILABLE
public static final int ERROR_NFC_NOT_AVAILABLEDevice does not support NFC.- See Also:
-
ERROR_BLE_SCAN_NOT_ACTIVE
public static final int ERROR_BLE_SCAN_NOT_ACTIVEBluetooth scan is not active.- See Also:
-
ERROR_SECURE_DEVICE_LOCK_NOT_ENABLED
Deprecated.Requirement of having device lock enabled has been removed from SDK, hence this error code has been deprecated.- See Also:
-
ERROR_ANOTHER_OPERATION_ONGOING
public static final int ERROR_ANOTHER_OPERATION_ONGOINGAnother operation is already ongoing.- See Also:
-
ERROR_TIMEOUT
public static final int ERROR_TIMEOUTTimeout occurred- See Also:
-
ERROR_RESOURCE_NULL
public static final int ERROR_RESOURCE_NULLBitwardsResource instance is null- See Also:
-
ERROR_AUTH_TOKEN_EXPIRED
public static final int ERROR_AUTH_TOKEN_EXPIREDAuthentication token with the server has expired, sign in again needed.- See Also:
-
ERROR_UNKNOWN_BACKGROUND_SCAN_MODE
public static final int ERROR_UNKNOWN_BACKGROUND_SCAN_MODEUnknown background scan mode.- See Also:
-
ERROR_INSTALLATION_NOT_ACTIVE
public static final int ERROR_INSTALLATION_NOT_ACTIVEInstallation is not active.- See Also:
-
ERROR_INSTALLATION_ACTIVE
public static final int ERROR_INSTALLATION_ACTIVEInstallation is active.- See Also:
-
ERROR_INSTALLATION_FAILED
public static final int ERROR_INSTALLATION_FAILEDInstallation failed.- See Also:
-
ERROR_RESOURCE_ALREADY_INSTALLED
public static final int ERROR_RESOURCE_ALREADY_INSTALLEDInstallation failed because the resoruce was already installed.- See Also:
-
ERROR_INSTALLATION_TASK_NOT_PENDING
public static final int ERROR_INSTALLATION_TASK_NOT_PENDINGInstallation task is not in pending mode (it has been already performed)- See Also:
-
ERROR_WRONG_INSTALLATION_TASK_CANCELLED
public static final int ERROR_WRONG_INSTALLATION_TASK_CANCELLEDInstallation task to be cancelled was not the active one.- See Also:
-
ERROR_INSTALLATION_TASK_CANCELLED
public static final int ERROR_INSTALLATION_TASK_CANCELLEDInstallation task was cancelled- See Also:
-
ERROR_SERVER_RESPONSE_RESOURCE_ALREADY_INSTALLED
public static final int ERROR_SERVER_RESPONSE_RESOURCE_ALREADY_INSTALLEDInstallation failed because the Bitwards resource was already installed response by server.- See Also:
-
ERROR_SERVER_RESPONSE_INTERNAL_ERROR
public static final int ERROR_SERVER_RESPONSE_INTERNAL_ERRORInstallation failed because internal error response by server.- See Also:
-
ERROR_SERVER_RESPONSE_FAILED_TO_ADD_NEW_RESOURCE_IN_SERVER
public static final int ERROR_SERVER_RESPONSE_FAILED_TO_ADD_NEW_RESOURCE_IN_SERVERInstallation failed because server failed to new Bitwards resource response by server.- See Also:
-
ERROR_SERVER_RESPONSE_SERIAL_NUMBER_ALREADY_EXISTS
public static final int ERROR_SERVER_RESPONSE_SERIAL_NUMBER_ALREADY_EXISTSInstallation failed because serial number already exists response by server.- See Also:
-
ERROR_SERVER_RESPONSE_CANCEL_RESOURCE_RESERVATION_FAILED
public static final int ERROR_SERVER_RESPONSE_CANCEL_RESOURCE_RESERVATION_FAILEDCancel Bitwards resource reservation failed response by server.- See Also:
-
ERROR_CANCEL_RESOURCE_RESERVATION_SERVER_COMMUNICATION
public static final int ERROR_CANCEL_RESOURCE_RESERVATION_SERVER_COMMUNICATIONCancel Bitwards resource reservation server communication error.- See Also:
-
ERROR_SERVER_RESPONSE_RESOURCE_RESERVATION_FAILED
public static final int ERROR_SERVER_RESPONSE_RESOURCE_RESERVATION_FAILEDBitwards resource reservation failed response by server.- See Also:
-
ERROR_RESOURCE_RESERVATION_SERVER_COMMUNICATION
public static final int ERROR_RESOURCE_RESERVATION_SERVER_COMMUNICATIONBitwards resource reservation server communication error.- See Also:
-
ERROR_SERVER_RESPONSE_GET_LOCATION_LIST_FAILED
public static final int ERROR_SERVER_RESPONSE_GET_LOCATION_LIST_FAILEDGet location list failed response by server.- See Also:
-
ERROR_GET_LOCATION_LIST_SERVER_COMMUNICATION
public static final int ERROR_GET_LOCATION_LIST_SERVER_COMMUNICATIONGet location list server communication error.- See Also:
-
ERROR_REFRESH_FAILED
public static final int ERROR_REFRESH_FAILEDRefresh connection to server failed.- See Also:
-
ERROR_INSTALLATION_TEST_FAILED
public static final int ERROR_INSTALLATION_TEST_FAILEDTesting access to the installed Bitwards resource failed, but installation was otherwise carried out successfully. All installation messages were delivered successfully, but testing the installation with test token failed.- See Also:
-
ERROR_LOCATION_SERVICE_DISABLED
public static final int ERROR_LOCATION_SERVICE_DISABLEDAndroid device's Location service is disabled. It needs to be enabled in order to have Bluetooth scanning to work.- See Also:
-
ERROR_RESOURCE_UPDATE_FAILED
public static final int ERROR_RESOURCE_UPDATE_FAILEDUpdate process of the Bitwards resource failed.- See Also:
-
ERROR_RESOURCE_UPDATE_ACTIVE
public static final int ERROR_RESOURCE_UPDATE_ACTIVEAnother Bitwards resource update process is active.- See Also:
-
ERROR_RESOURCE_UPDATE_TASK_CANCELLED
public static final int ERROR_RESOURCE_UPDATE_TASK_CANCELLEDBitwards resource update task was cancelled.- See Also:
-
ERROR_RESOURCE_UPDATE_NOT_ACTIVE
public static final int ERROR_RESOURCE_UPDATE_NOT_ACTIVEBitwards resource update process is not active.- See Also:
-
ERROR_WRONG_RESOURCE_UPDATE_TASK_CANCELLED
public static final int ERROR_WRONG_RESOURCE_UPDATE_TASK_CANCELLEDWrong Bitwards resource update task was cancelled.- See Also:
-
ERROR_BACKGROUND_SCAN_STOPPED
public static final int ERROR_BACKGROUND_SCAN_STOPPEDBackground scan was stopped manually.- See Also:
-
ERROR_ACCESS_FORBIDDEN
public static final int ERROR_ACCESS_FORBIDDENThe logged in end user does not have the permission to access the requested service.- See Also:
-
ERROR_LOGIN_FAILED_BECAUSE_USER_DOES_NOT_EXISTS
public static final int ERROR_LOGIN_FAILED_BECAUSE_USER_DOES_NOT_EXISTSLogin failed because user does not exist.- See Also:
-
ERROR_NO_BLUETOOTH_SCAN_PERMISSION
public static final int ERROR_NO_BLUETOOTH_SCAN_PERMISSIONThe application does not have the BLUETOOTH_SCAN permission.- See Also:
-
ERROR_NO_BLUETOOTH_CONNECT_PERMISSION
public static final int ERROR_NO_BLUETOOTH_CONNECT_PERMISSIONThe application does not have the BLUETOOTH_CONNECT permission.- See Also:
-
ERROR_ACCOUNT_DELETION_FAILED
public static final int ERROR_ACCOUNT_DELETION_FAILEDThe application does not have the BLUETOOTH_CONNECT permission.- See Also:
-
ERROR_RELOGIN_REQUIRED
public static final int ERROR_RELOGIN_REQUIREDLogout reason: The refresh of the authentication token with OAuth2 failed because end user needs to re-login.- See Also:
-
ERROR_USER_LOGGED_OUT
public static final int ERROR_USER_LOGGED_OUTLogout reason: End user logged out.- See Also:
-
REASON_HANDLE_IN_WRONG_POSITION
public static final int REASON_HANDLE_IN_WRONG_POSITIONOperation with Bitwards resource failed: handle is in wrong position- See Also:
-
REASON_BAD_DATA
public static final int REASON_BAD_DATAOperation with Bitwards resource failed: bad data.- See Also:
-
REASON_WRONG_SIGNATURE
public static final int REASON_WRONG_SIGNATUREOperation with Bitwards resource failed: bad signature.- See Also:
-
REASON_WRONG_DELEGATION
public static final int REASON_WRONG_DELEGATIONOperation with Bitwards resource failed: wrong delegation.- See Also:
-
REASON_DELEGATION_USED
public static final int REASON_DELEGATION_USEDOperation with Bitwards resource failed: delegation used.- See Also:
-
REASON_DELEGATION_CACHE_OVERRUN
public static final int REASON_DELEGATION_CACHE_OVERRUNOperation with Bitwards resource failed: delegation cache overrun.- See Also:
-
REASON_TOKEN_BLACKLISTED
public static final int REASON_TOKEN_BLACKLISTEDOperation with Bitwards resource failed: token is blacklisted.- See Also:
-
REASON_WRONG_TIME_WINDOW
public static final int REASON_WRONG_TIME_WINDOWOperation with Bitwards resource failed: token has wrong time window.- See Also:
-
REASON_CREATIONTIME_IN_FUTURE
public static final int REASON_CREATIONTIME_IN_FUTUREOperation with Bitwards resource failed: token creation time in future.- See Also:
-
REASON_RESOURCE_ALREADY_RESERVED
public static final int REASON_RESOURCE_ALREADY_RESERVEDOperation with Bitwards resource failed: resource is already reserved.- See Also:
-
REASON_ILLEGAL_USER_ROLE
public static final int REASON_ILLEGAL_USER_ROLEOperation with Bitwards resource failed: token owner has illegal user role.- See Also:
-
REASON_PERIPHERAL_FAILURE
public static final int REASON_PERIPHERAL_FAILUREOperation with Bitwards resource failed: peripheral failure occurred.- See Also:
-
REASON_PERIPHERAL_COMMUNICATION_FAILURE
public static final int REASON_PERIPHERAL_COMMUNICATION_FAILUREOperation with Bitwards resource failed: peripheral communication failure occurred.- See Also:
-
REASON_OPERATION_FAILED_BATTERY_CRITICAL
public static final int REASON_OPERATION_FAILED_BATTERY_CRITICALOperation with Bitwards resource failed: operation failed due to resource's battery being critical.- See Also:
-
REASON_OPERATION_DENIED_BY_REGULAR_SCHEDULE
public static final int REASON_OPERATION_DENIED_BY_REGULAR_SCHEDULEOperation with Bitwards resource failed: access denied due to regular schedule access list.- See Also:
-
REASON_OPERATION_DENIED_BY_EXCEPTION_SCHEDULE
public static final int REASON_OPERATION_DENIED_BY_EXCEPTION_SCHEDULEOperation with Bitwards resource failed: access denied due to exception schedule.- See Also:
-
REASON_NO_VALID_TOKEN
public static final int REASON_NO_VALID_TOKENOperation with Bitwards resource failed: application does not have have a valid token for the resource.- See Also:
-
ERROR_RESOURCE_REQUIRES_APP_UPDATE
public static final int ERROR_RESOURCE_REQUIRES_APP_UPDATEOperation with Bitwards resource failed: application does not support the protocol resource is using, application update is required.- See Also:
-
-
Method Details
-
getInstance
public static BitwardsService getInstance(android.content.Context context, String license) throws BitwardsException Get BitwardsService instance. The BitwardsService instance is a singleton,i.e., this method always returns the same BitwardsService instance.- Parameters:
context- the application contextlicense- the Bitwards lisence (json file obtained from Bitwards)- Returns:
- BitwardsService instance (singleton)
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getInstance
Deprecated.Deprecated, usegetInstance(Context, String)instead.- Returns:
- BitwardsService instance.
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
initialize
@Deprecated public void initialize(BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, this method does not need to be used. BitwardsService instance is initialized whengetInstance(Context, String)method is called. Initialized BitwardsService instance. Must be called once, typically right after BitwardsService.getInstance(Context,String).- Parameters:
callback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
initialize
Deprecated.Deprecated, this method does not need to be used. BitwardsService instance is initialized whengetInstance(Context, String)method is called. Initialized BitwardsService instance. Must be called once. Not recommended to be used, useinitialize(ResultCallback)instead.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
connect
@Deprecated public void connect(String url, String username, String password, BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, uselogin(BitwardsCredential, ResultCallback)instead. Connect (log in) to Bitwards backend environment. In other words, end user logs in to the server.- Parameters:
url- the url to Bitwards serverusername- end user's username (typically end user's email address)password- end user's passwordcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
login
public void login(BitwardsCredential credential, BitwardsService.ResultCallback callback) throws BitwardsException Login to Bitwards backend environment. In other words, end user logs in to the server.- Parameters:
credential- end user's credentialcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
connect
@Deprecated public void connect(String url, BitwardsCredential credential, BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, uselogin(BitwardsCredential, ResultCallback)instead. Connect (log in) to Bitwards backend environment. In other words, end user logs in to the server.- Parameters:
url- the url to Bitwards servercredential- end user's credentialcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
refresh
public void refresh(BitwardsCredential credential, BitwardsService.ResultCallback callback) throws BitwardsException Refresh connection to Bitwards backend environment using new BitwardsCredential. Connection to server is refreshed to use new credential without disconnecting from server (ie, there is no logout). This is typically done when the authentication token is about to expire.- Parameters:
credential- new end user's credentialcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
logout
Deprecated.Deprecated, uselogout()instead.- Parameters:
callback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
logout
Log out from Bitwards backend environment. In other words, end user logs out from the server.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
disconnect
@Deprecated public void disconnect(BitwardsService.ResultCallback callback) throws BitwardsException Deprecated.Deprecated, uselogout()instead.- Parameters:
callback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
disconnect
Deprecated.Deprecated, uselogout()instead.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
isInitialized
Deprecated.Deprecated, this method does not need to be used. BitwardsService instance is always initialized successfully when usinggetInstance(Context, String), hence this method always returns boolean value true.- Returns:
- true if initialized, false if not.
-
isConnected
Deprecated.Deprecated, useisLoggedIn()instead. Check if BitwardsService instance is connected (logged in) to Bitwards backend environment. In other words, if end user is logged into the server or not.- Returns:
- true if connected (logged in), false if not.
-
isLoggedIn
public boolean isLoggedIn()Check if BitwardsService instance is logged in to Bitwards backend environment. In other words, if end user is logged into the server or not.- Returns:
- true if logged in, false if not.
-
isAuthenticationTokenValid
Deprecated.Deprecated, use
isAuthenticationTokenValid(ResultCallback)instead.Check if authentication token used with the Bitwards backend environment is valid. Calling this method may potentially take a long time as it may involve communication with the backend server, and
isAuthenticationTokenValid(ResultCallback)should be used instead.- Returns:
- true if authentication token valid, false if not.
- Throws:
BitwardsException
-
isAuthenticationTokenValid
Check if authentication token used with the Bitwards backend environment is valid. If the device does not have network connectivity, the authentication token is considered to be valid.- Parameters:
callback- if authentication token is valid, onSuccess() is called; otherwise onError() is called withERROR_AUTH_TOKEN_EXPIREDorERROR_NOT_LOGGED_INerror code.
-
isBackgroundScanActive
public boolean isBackgroundScanActive()Check if BitwardsService instance has the background bluetooth scan is active.- Returns:
- true if the background bluetooth scan is active, false if not.
-
isOperationActive
public boolean isOperationActive()Check if BitwardsService instance has an asynchronous operation active. BitwardsService instance can have only one asynchronous operation active at a time.- Returns:
- true if another asynchronous operation is active, false if not.
-
changePassword
public void changePassword(String oldPassword, String newPassword, BitwardsService.ResultCallback callback) throws BitwardsException Change password of the logged in Bitwards end user.- Parameters:
oldPassword- the old passwordnewPassword- the new passwordcallback- the callback to return success notification or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
changePassword
@Deprecated public void changePassword(String oldPassword, String newPassword) throws BitwardsException Deprecated.Deprecated, usechangePassword(String, String, ResultCallback)instead. Change password of the logged in Bitwards end user.- Parameters:
oldPassword- the new passwordnewPassword- the old password- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsUser
@Deprecated public void getBitwardsUser(BitwardsService.BitwardsUserCallback callback) throws BitwardsException Deprecated.Deprecated, usegetBitwardsUser()instead. Get profile properties of the logged in Bitwards end user.- Parameters:
callback- the callback to return end user's profile properties or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsUser
Get profile properties of the logged in Bitwards end user.- Returns:
- Bitwards user data
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
updateBitwardsUser
public void updateBitwardsUser(BitwardsUser user, BitwardsService.BitwardsUserCallback callback) throws BitwardsException Change profile data of the logged in Bitwards end user.- Parameters:
user- the modified Bitwards end user profile datacallback- the callback to return updated end user profile data or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
updateBitwardsUser
Deprecated.Deprecated, useupdateBitwardsUser(BitwardsUser, BitwardsUserCallback)instead. Change profile data of the logged in Bitwards end user.- Parameters:
user- the modified Bitwards end user profile data- Returns:
- the Bitwards end user profile data on the server after update.
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
synchronize
Synchronize the local SDK database (e.g., Bitwards resource list and user data) with the Bitwards backend server.- Parameters:
callback- the callback to return success or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceList
@Deprecated public void getBitwardsResourceList(boolean sync, BitwardsService.BitwardsResourceListCallback callback) throws BitwardsException Deprecated.Deprecated, usegetBitwardsResourceList()instead, andsynchronize(ResultCallback)to synchronize the local SDK database with the Backend server. Get the Bitwards resource list of the logged in Bitwards end user, optionally synchronize the Bitwards resource list from the Bitwards backend environment.- Parameters:
sync- do synchronize with the server or notcallback- the callback to return list of end users's Bitwards resources or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsInstallationRequestList
public void getBitwardsInstallationRequestList(boolean sync, BitwardsService.BitwardsInstallationRequestListCallback callback) throws BitwardsException Get the Bitwards resource installation request list of the Bitwards end user.- Parameters:
sync- do synchronize with the server or notcallback- the callback to return list of installation request or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceTypeList
public void getBitwardsResourceTypeList(boolean sync, BitwardsService.BitwardsResourceTypeListCallback callback) throws BitwardsException Get the resource type list of the Bitwards resources.- Parameters:
sync- do synchronize with the server or notcallback- the callback to return list of resource type or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceList
@Deprecated public List<BitwardsResource> getBitwardsResourceList(boolean sync) throws BitwardsException Deprecated.Deprecated, usegetBitwardsResourceList()instead, andsynchronize(ResultCallback)to synchronize the local SDK database with the Backend server. Get the Bitwards resource list of the logged in Bitwards end user.- Parameters:
sync- do synchronize with the server or not- Returns:
- list of Bitwards resources that the logged in end user knows about
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsResourceList
Get the Bitwards resource list of the logged in Bitwards end user. Not recommended to be used, usegetBitwardsUser(BitwardsUserCallback)instead.- Returns:
- list of Bitwards resources that the logged in end user knows about.
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsAdminInfoList
Get the Bitwards admin info list of the logged in Bitwards end user.- Returns:
- list of end users's account admin information
- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
getBitwardsAdminIfoList
Deprecated.Deprecated, usegetBitwardsAdminInfoList()instead.- Throws:
BitwardsException
-
deleteUserAccount
public void deleteUserAccount(List<Long> accountIDs, BitwardsService.ResultCallback callback) throws BitwardsException todo add documentation- Parameters:
callback- the callback to return success or error code if something went wrong- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
setNFCResourceCallback
public void setNFCResourceCallback(BitwardsService.NFCResourceCallback callback) throws BitwardsException Set the callback for NFC based Bitwards resource event callbacks. This callback is used when BitwardsService instance has communicating with a Bitwards resource over NFC.- Parameters:
callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
discoverAndAccessResource
public void discoverAndAccessResource(BitwardsService.BLEResourceCallback callback) throws BitwardsException Start a bluetooth scan for discovering BLE based Bitwards resources that are known to end user. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
scanForResource
@Deprecated public void scanForResource(BitwardsService.BLEResourceCallback callback) throws BitwardsException Deprecated.Deprecated, usediscoverAndAccessResource(BLEResourceCallback)instead. Start a bluetooth scan for discovering BLE based Bitwards resources that are known to end user. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
discoverAndAccessResource
public void discoverAndAccessResource(BitwardsService.BLEResourceCallback callback, int mode) throws BitwardsException Start bluetooth scan for discovering BLE based Bitwards resources. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting resultmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
scanForResource
@Deprecated public void scanForResource(BitwardsService.BLEResourceCallback callback, int mode) throws BitwardsException Deprecated.Deprecated, usediscoverAndAccessResource(BLEResourceCallback, int)instead. Start bluetooth scan for discovering BLE based Bitwards resources. Result of the scan, i.e., list of discovered Bitwards resources will be reported back using the callback.- Parameters:
callback- the callback for reporting resultmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
maintainResource
public void maintainResource(BitwardsResource resource, BitwardsService.BLEResourceMaintenanceCallback callback) throws BitwardsException Attempt to connect to and execute maintenance with a Bitwards resource using BLE. Result of the connection attempt will be reported back using resource maintenance callback.- Parameters:
resource- the Bitwards resource to connect to.callback- the callback for reporting result of the maintenance- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
accessResource
public void accessResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) throws BitwardsException Attempt to connect to and access a Bitwards resource using BLE. Result of the connection attempt will be reported back using resource callback.- Parameters:
resource- the Bitwards resource to connect to.callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
scanAndAccessResource
public void scanAndAccessResource(BitwardsResource resource, long scanTime, BitwardsService.BLEResourceCallback callback) throws BitwardsException Scan for the given resource and if found, access the resource. Result of the scan and access attempt is reported back using resource callback.- Parameters:
resource- the Bitwards Resource to access.scanTime- the time in milliseconds how long to scan for the given resource. If resource is not found onResourceNotFound(..) is called.callback- the callback for reporting result- Throws:
BitwardsException
-
connectToResource
@Deprecated public void connectToResource(BitwardsResource resource, BitwardsService.BLEResourceCallback callback) throws BitwardsException Deprecated.Deprecated, useaccessResource(BitwardsResource, BLEResourceCallback)instead. Attempt to connect to and access a Bitwards resource using BLE. Result of the connection attempt will be reported back using resource callback.- Parameters:
resource- the Bitwards resource to connect to.callback- the callback for reporting result- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
startBackgroundScan
@Deprecated public void startBackgroundScan(BitwardsService.BackgroundScanCallback callback) throws BitwardsException Deprecated.Deprecated, useregisterBackgroundScanCallback(BackgroundScanCallback)instead. Start the BLE background scan to discover Bitwards resources that are known to Bitwards end user (see NOTE). Results of scan will be reported using the callback.
NOTE: This method is deprecated. UseregisterBackgroundScanCallback(BackgroundScanCallback)andunregisterBackgroundScanCallback(BackgroundScanCallback)to perform the discovery of Bitwards resources using BLE.- Parameters:
callback- the background scan callback interface for reporting found/lost Bitwards resources- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
startBackgroundScan
@Deprecated public void startBackgroundScan(BitwardsService.BackgroundScanCallback callback, int mode) throws BitwardsException Deprecated.Deprecated, useregisterBackgroundScanCallback(BackgroundScanCallback, int)instead. Start the BLE background scan to discover Bitwards resources, optionally also unknown Bitwards resources to Bitwards end user are included. Results of scan will be reported using the callback.
NOTE: This method is deprecated. UseregisterBackgroundScanCallback(BackgroundScanCallback,int)andunregisterBackgroundScanCallback(BackgroundScanCallback)to perform the discovery of Bitwards resources using BLE.- Parameters:
callback- the background scan callback interface for reporting found/lost Bitwards resourcesmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
stopBackgroundScan
Stop the ongoing BLE background scan.NOTE: It is recommended not to use this method to stop the background scan. Each BackgroundScanCallback instance registered with
registerBackgroundScanCallback(BackgroundScanCallback)orregisterBackgroundScanCallback(BackgroundScanCallback, int)should be unregistered withunregisterBackgroundScanCallback(BackgroundScanCallback).If there are any existing BackgroundScanCallback instances registered with
registerBackgroundScanCallback(BackgroundScanCallback)orregisterBackgroundScanCallback(BackgroundScanCallback, int)methods, those are also stopped, and the corresponding callback instance will receiveBitwardsService.BackgroundScanCallback.onError(int)call with ERROR_BACKGROUND_SCAN_STOPPED as the error code.- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
registerBackgroundScanCallback
public void registerBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback) throws BitwardsException Register a BackgroundScanCallback instance to discover BLE based Bitwards resources that are known to the logged in Bitwards end user.- Parameters:
callback- the background scan callback instance- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
registerBackgroundScanCallback
public void registerBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback, int mode) throws BitwardsException Register a BackgroundScanCallback instance to discover BLE based Bitwards resources, optionally also unknown Bitwards resources to the logged in Bitwards end user are included.- Parameters:
callback- the callback instance to be registeredmode- the mode of background scan (useRESOURCE_SCAN_MODE_FULLorRESOURCE_SCAN_MODE_KNOWNorRESOURCE_SCAN_MODE_UNIVERSAL).- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
unregisterBackgroundScanCallback
public void unregisterBackgroundScanCallback(BitwardsService.BackgroundScanCallback callback) throws BitwardsException Unregister a BackgroundScanCallback instance.- Parameters:
callback- the callback instance to be unregistered- Throws:
BitwardsException- thrown if operation failed, useBitwardsException.getErrorCode()to find out which error.
-
startBluetoothProximityAccess
public void startBluetoothProximityAccess(BitwardsService.BluetoothProximityAccess access) throws BitwardsException Start Bitwards resource discovery for proximity access.- Parameters:
access- the bluetooth proximity access instance for discovering and triggering proximity access Bitwards resources.- Throws:
BitwardsException- thrown if an exception occurred
-
stopBluetoothProximityAccess
public void stopBluetoothProximityAccess(BitwardsService.BluetoothProximityAccess access) throws BitwardsException Stop Bitwards resource discovery for proximity access.- Parameters:
access- the bluetooth proximity access instance that was previously used to start the discovery and triggering proximity access for Bitwards resources.- Throws:
BitwardsException- thrown if an exception occurred
-
pauseNfc
public void pauseNfc()Pause processing of NFC connections from Bitwards resources. The BitwardsService instance will not process any connections from NFC based Bitwards resources, i.e., they are ignored. This does not affect the status of the NFC adapter in the device (it is not turned off). -
resumeNfc
public void resumeNfc()Resume processing of NFC connections from Bitwards resources. The BitwardsService instance will process connections from NFC based Bitwards resources normally. This does not affect the status of the NFC adapter in the device (it is not turned on). -
isNfcPaused
public boolean isNfcPaused()Check if the processing of NFC connections is paused.- Returns:
- true, if processing of NFC connections is paused; false, if processing is not paused
-
getVersion
Get the version of the BitwardsService instance.- Returns:
- the version of the BitwardsService
-
setNotifier
Set BitwardsService.Notifier class. The class must be a real class, not an anonymous class. SeeBitwardsService.Notifierinterface for details.- Parameters:
clazz- a class that implementsBitwardsService.Notifierinterface
-
setBitwardsConfig
Set default settings for BitwardsService instance. Default settings are only set if there is no existing setting value.- Parameters:
config- the BitwardsConfig instance
-
setAuthenticationTokenExpiredCallback
public void setAuthenticationTokenExpiredCallback(BitwardsService.AuthenticationTokenExpiredCallback callback) Set callback for receiving notifications when the authentiation token has expired. This means that the connection to the server is not active any more.- Parameters:
callback- the callback
-
setBitwardsResourceListUpdatedCallback
public void setBitwardsResourceListUpdatedCallback(BitwardsService.BitwardsResourceListUpdatedCallback callback) Set the callback for receiving notifications when the list of Bitwards resources for the logged in Bitwards end user has been updated automatically. This typically happens when BitwardsService instance synchronizes the resource list with the Bitwards backend environment automatically.- Parameters:
callback- the callback
-
getLogoutReason
public int getLogoutReason()Get reason for the most recent logout whenBitwardsService.AuthenticationTokenExpiredCallbackhas been used.- Returns:
- the logout reason
-