Skip to content

Mobile Keys

A Mobile Key is a short-lived key (usually several days) issued based on a Grant and can be used for unlocking. Mobile Keys are cached by the Tapkey Mobile SDK for Android, so they can be used for unlocking even if the mobile device is offline. To ensure that Mobile Keys are always up to date, they need to be periodically renewed, which usually happens in the background. It is recommended to configure Push Notifications for this purpose.

For more details on keeping Mobile Keys in sync, please refer to the section Keep data up to date.

The KeyManager, obtained through the TapkeyServiceFactory, provides access to the Mobile Keys.

KeyManager keyManager = tapkeyServiceFactory.getKeyManager();

To retrieve a list of Mobile Keys, you can use the method getLocalKeys(String userId). These Mobile Keys are locally stored and available offline. Calling this method does not trigger a refresh.

List<KeyDetails> localKeys = keyManager.getLocalKeys(userId);

To retrieve a specific Mobile Key for a lock, you can use the method getLocalKey(String userId, String grantId, String physicalLockId).

KeyDetails localKey = keyManager.getLocalKey(userId, grantId, physicalLockId);

To react to changes in the Mobile Keys, you can obtain an observable using the

method getKeyUpdateObservable().

ObservableRegistration observableRegistration = keyManager.getKeyUpdateObservable().addObserver(keyChangedNotification -> {
    // ToDo: React based on the event
});

// Close observable if not needed anymore
observableRegistration.close();