Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 1.99 KB

PushReceiverLegacy.md

File metadata and controls

46 lines (37 loc) · 1.99 KB

class PushReceiverLegacy

Wraps PushReceiver with the configuration and credentials shape used by @eneris/push-receiver. It builds the FirebaseApp internally from the flat config object and maps stored credentials to the new storage layout.

Use it only when migrating an existing integration - new code should use PushReceiver.

Config

const client = new PushReceiverLegacy({
    firebase: { projectId, appId, apiKey, messagingSenderId },
    credentials,        // previously persisted credentials, optional
    persistentIds: [],  // ids of already received messages
    bundleId: undefined, // 'receiver.push.com',
    chromeId: undefined, // 'org.chromium.linux',
    chromePlatform: undefined,  // 1 = Windows, 2 = Darwin, 3 = Linux, 4 = Cros, 5 = iOS
    chromeChannel: undefined,   // 1 = stable, 2 = beta, 3 = dev, 4 = canary, 5 = unknown
    chromeVersion: undefined, // '148.0.7778.271',
    timeZone: undefined, // 'Europe/Prague',
    vapidKey: undefined,
    heartbeatIntervalMs: 5 * 60 * 1000,
    maxRetryAttempts: 0,  // optional, defaults to 0; non-positive value disables the limit
    debug: false,
})

Methods

registerIfNeeded

  • Returns existing credentials and performs a check-in when they are still valid
  • Otherwise runs a full GCM + FCM registration and returns the new credentials

onCredentialsChanged

  • Subscribes to ON_CREDENTIALS_CHANGE, returns a dispose function
  • Persist the emitted credentials to reuse the same token after a restart

checkCredentials

  • Validates the given (or currently configured) credentials against the config

setDebug

  • Toggles debug logging at runtime

Properties

  • config - normalized config with defaults applied
  • fcmToken - token from the legacy credentials, falling back to the base class
  • persistentIds - readable and writable list of already processed message ids

All members of PushReceiver are inherited.