as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

Step 6: Schedule EPG for App Install or Update

You must create or update the onInstallOrUpdateTask to schedule your EPG Sync Task.

Step 1: Declare onInstallOrUpdateTask in the manifest file

Copied to clipboard.

[components]
## <other components related entries>
[[components.task]]
## Define the task that needs to run "On App Install/Update"
id = "<packageId>.onInstallOrUpdateTask"
runtime-module = "/com.amazon.kepler.headless.runtime.loader_2@IKeplerScript_2_0"

## Define a process group for each component
[processes]
## <other process related entries>
[[processes.group]]
component-ids = ["<packageId>.onInstallOrUpdateTask"]

[tasks]
## Ask the system to run your 'onInstallOrUpdateTask' task on installation and app updates
[[tasks.work]]
component-id = "<packageId>.onInstallOrUpdateTask"
mode = "install"

Step 2: Define your app's task

Define your app’s onInstallOrUpdateTask by creating a OnInstallOrUpdate.ts file in your src folder with the following content. This task runs on app installations and updates.

Copied to clipboard.

import {EpgSyncTaskScheduler} from '@amazon-devices/kepler-epg-sync-scheduler';
import { UtcTimePropertiesBuilder } from '@amazon-devices/kepler-epg-sync-scheduler';

const doTask = async (): Promise<void> => {
  console.info('Scheduling EPG Sync task');
  // TODO: If the customer is entitled to any channels in your app,
  // choose one of the options below to schedule an EPG sync task.

  // If you call 'scheduleTask()' or 'scheduleTaskWithExecutionWindow()' multiple times,
  // the most recent EPG Sync Task method call will be fulfilled and persisted across reboots.

  // Option 1: Schedule EPG Sync task with a given interval.
  // If this is enabled, Please ensure that the test for `scheduleTask` is enabled in tst/task/OnInstallOrUpdateTask.test.ts
  await EpgSyncTaskScheduler.scheduleTask(
    '<packageId>.epgSyncTask', // component id of the sync task
    60 * 24, // 24 hours in mins
  );

  // Option 2: Schedule task with a execution window, i.e. run task between 2am - 4am UTC every day.
  // If this is enabled, Please ensure that the test for `scheduleTaskWithExecutionWindow` is enabled in tst/task/OnInstallOrUpdateTask.test.ts
  // let timeProperties = new UtcTimePropertiesBuilder()
  //   .startHour(2)
  //   .startMinute(0)
  //   .startSecond(0)
  //   .executionWindowInMinutes(120)
  //   .build();
  // await EpgSyncTaskScheduler.scheduleTaskWithExecutionWindow(
  //   '<packageId>.epgSyncTask', // component id of the sync task
  //   timeProperties,
  // );
};

export default doTask;

When your onInstallOrUpdate task runs, you should see a log line similar to the following.

Copied to clipboard.

INFO ktf.tm.nests:Successfully scheduled EPG Sync task

Last updated: Sep 30, 2025