Search in sources :

Example 1 with SyncKeyValue

use of im.actor.runtime.storage.SyncKeyValue in project actor-platform by actorapp.

the class NotificationsActor method preStart.

@Override
public void preStart() {
    isMobilePlatform = config().getPlatformType() == PlatformType.ANDROID || config().getPlatformType() == PlatformType.IOS;
    // Building storage
    storage = new SyncKeyValue(Storage.createKeyValue(STORAGE_NOTIFICATIONS));
    // Loading pending messages
    pendingStorage = new PendingStorage(MAX_NOTIFICATION_COUNT);
    byte[] storage = this.storage.get(0);
    if (storage != null) {
        try {
            pendingStorage = PendingStorage.fromBytes(storage, MAX_NOTIFICATION_COUNT);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    subscribe(AppVisibleChanged.EVENT);
    subscribe(PeerChatOpened.EVENT);
    subscribe(PeerChatClosed.EVENT);
}
Also used : PendingStorage(im.actor.core.modules.notifications.entity.PendingStorage) SyncKeyValue(im.actor.runtime.storage.SyncKeyValue) IOException(java.io.IOException)

Aggregations

PendingStorage (im.actor.core.modules.notifications.entity.PendingStorage)1 SyncKeyValue (im.actor.runtime.storage.SyncKeyValue)1 IOException (java.io.IOException)1