android-components / mozilla.components.feature.push / AutoPushFeature

AutoPushFeature

class AutoPushFeature : PushProcessor, Observable<Observer> (source)

A implementation of a PushProcessor that should live as a singleton by being installed in the Application’s onCreate. It receives messages from a service and forwards them to be decrypted and routed.

Listen for subscription information changes for each registered scope:

Listen also for push messages:

Types

Name Summary
Observer interface Observer
Observers that want to receive updates for new subscriptions and messages.

Constructors

| Name | Summary | |—|—| | <init> | AutoPushFeature(context: <ERROR CLASS>, service: PushService, config: PushConfig, coroutineContext: CoroutineContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher(), connection: PushConnection = RustPushConnection( senderId = config.senderId, serverHost = config.serverHost, socketProtocol = config.protocol, serviceType = config.serviceType, databasePath = File(context.filesDir, DB_NAME).canonicalPath ), crashReporter: CrashReporting? = null)
A implementation of a PushProcessor that should live as a singleton by being installed in the Application’s onCreate. It receives messages from a service and forwards them to be decrypted and routed. |

Functions

Name Summary
getSubscription fun getSubscription(scope: String, appServerKey: String? = null, block: (AutoPushSubscription?) -> Unit): Unit
Checks if a subscription for the scope already exists.
initialize fun initialize(): Unit
Starts the push feature and initialization work needed. Also starts the PushService to ensure new messages come through.
onError fun onError(error: PushError): Unit
An error has occurred.
onMessageReceived fun onMessageReceived(message: EncryptedPushMessage): Unit
New encrypted messages received from a supported push messaging service.
onNewToken fun onNewToken(newToken: String): Unit
New registration tokens are received and sent to the AutoPush server which also performs subscriptions for each push type and notifies the subscribers.
renewRegistration fun renewRegistration(): Unit
Deletes the registration token locally so that it forces the service to get a new one the next time hits it’s messaging server.
shutdown fun shutdown(): Unit
Un-subscribes from all push message channels and stops periodic verifications.
subscribe fun subscribe(scope: String, appServerKey: String? = null, onSubscribeError: () -> Unit = {}, onSubscribe: (AutoPushSubscription) -> Unit = {}): Unit
Subscribes for push notifications and invokes the onSubscribe callback with the subscription information.
unsubscribe fun unsubscribe(scope: String, onUnsubscribeError: () -> Unit = {}, onUnsubscribe: (Boolean) -> Unit = {}): Unit
Un-subscribes from a valid subscription and invokes the onUnsubscribe callback with the result.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.