Skip to main content
  • Snap

snap_getBackgroundEvents

Description

Get the scheduled background events for the Snap.

Parameters

null

The request parameters for the snap_getBackgroundEvents method.

This method does not accept any parameters.

Returns

array

The result returned by the snap_getBackgroundEvents method.

It consists of an array background events (if any) for a snap.

object

Background event type.

Note: The date generated when scheduling an event with a duration will be represented in UTC.

id

string

The unique id representing the event.

scheduledAt

string

The ISO 8601 time stamp of when the event was scheduled.

snapId

SnapId

The id of the snap that scheduled the event.

date

string

The ISO 8601 date of when the event is scheduled for.

request

object

The request that is supplied to the onCronjob handler when the event is fired.

method

string

jsonrpc

"2.0" | null

id

number | string | null

params

JsonRpcParams

Example

const events = await snap.request({
method: "snap_getBackgroundEvents",
});
console.log(events);
// [
// {
// id: 'event-1',
// scheduledAt: 1672531200000,
// snapId: 'npm:example-snap',
// date: 1672531200000,
// request: {
// method: 'example_method',
// params: { example: 'data' },
// },
// },
// ...,
// ]