snap_getBackgroundEvents
Description
Get the scheduled background events for the Snap.
Parameters
This method does not have any parameters.
Returns
object[]
An array of scheduled background events.
object
Background event type.
Note: The date generated when scheduling an event with a duration will be represented in UTC.
id
stringThe unique ID representing the event.
scheduledAt
stringThe ISO 8601 timestamp of when the event was scheduled.
snapId
SnapIdThe ID of the Snap that scheduled the event.
date
stringThe ISO 8601 date of when the event is scheduled for.
request
objectThe request that is supplied to the onCronjob handler
when the event is fired.
method
stringThe method to be called when the event is fired.
jsonrpc
"2.0" | nullThe optional JSON-RPC version for the request, which is always "2.0" if provided.
id
number | string | nullThe optional ID for the request.
params
JsonRpcParamsThe optional parameters for the request.
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' },
// },
// },
// ...,
// ]