API Documentation

class firebase_messaging.FcmPushClientConfig(server_heartbeat_interval=10, client_heartbeat_interval=20, send_selective_acknowledgements=True, connection_retry_count=5, start_seconds_before_retry_connect=3, reset_interval=3, heartbeat_ack_timeout=5, abort_on_sequential_error_count=3, monitor_interval=1, log_warn_limit=5, log_debug_verbose=False)[source]

Class to provide configuration to firebase_messaging.FcmPushClientConfig.FcmPushClient.

server_heartbeat_interval: Optional[int] = 10

Time in seconds to request the server to send heartbeats

client_heartbeat_interval: Optional[int] = 20

Time in seconds to send heartbeats to the server

send_selective_acknowledgements: bool = True

True to send selective acknowledgements for each message received. Currently if false the client does not send any acknowledgements.

connection_retry_count: int = 5

Number of times to retry the connection before giving up.

start_seconds_before_retry_connect: float = 3

Time in seconds to wait before attempting to retry the connection after failure.

reset_interval: float = 3

Time in seconds to wait between resets after errors or disconnection.

heartbeat_ack_timeout: float = 5

Time in seconds to wait for a heartbeat ack before resetting.

abort_on_sequential_error_count: Optional[int] = 3

Number of sequential errors of the same time to wait before aborting. If set to None the client will not abort.

monitor_interval: float = 1

Time in seconds for the monitor task to fire and check for heartbeats, stale connections and shut down of the main event loop.

log_warn_limit: Optional[int] = 5

Number of times to log specific warning messages before going silent for a specific warning type.

log_debug_verbose: bool = False

Set to True to log all message info including tokens.

class firebase_messaging.FcmPushClient(callback, fcm_config, credentials=None, credentials_updated_callback=None, *, callback_context=None, received_persistent_ids=None, config=None, http_client_session=None)[source]

Client that connects to Firebase Cloud Messaging and receives messages.

Parameters:
  • credentials (Optional[dict]) – credentials object returned by register()

  • credentials_updated_callback (Optional[Callable[[dict[str, Any]], None]]) – callback when new credentials are created to allow client to store them

  • received_persistent_ids (Optional[list[str]]) – any persistent id’s you already received.

  • config (Optional[FcmPushClientConfig]) – configuration class of firebase_messaging.FcmPushClientConfig

async checkin_or_register()[source]

Check in if you have credentials otherwise register as a new client.

Parameters:
  • sender_id – sender id identifying push service you are connecting to.

  • app_id – identifier for your application.

Return type:

str

Returns:

The FCM token which is used to identify you with the push end point application.

async start()[source]

Connect to FCM and start listening for push notifications.

Return type:

None

async stop()[source]
Return type:

None

is_started()[source]
Return type:

bool

async send_message(raw_data, persistent_id)[source]

Not implemented, does nothing atm.

Return type:

None