as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

Step 7: Schedule EPG Task for Entitlements

Your app may have several triggers which change the live content a customer is entitled to. Some examples of these are sign-in, sign-out, or subscription changes. At these trigger points, you can call EpgSyncTaskScheduler methods to schedule your EPG Sync Task.

If the customer is no longer entitled to any content, such as when a subscription is cancelled, do the following.

  1. Call ChannelLineupProvider.add([]) + ChannelLineupProvider.commit() and LiveEventProvider.add([]) + LiveEventProvider.commit() to clear the customer’s live content from the system.
  2. Call the cancelScheduledTasks() method to cancel any scheduled EPG sync tasks since no entitled content needs to be refreshed.

Here is an example code snippet demonstrating EpgSyncTaskScheduler usage in your onLogin() and onLogout callbacks.

Copied to clipboard.

import { EpgSyncTaskScheduler } from '@amazon-devices/kepler-epg-sync-scheduler';
import {
  ChannelLineupProvider,
  LiveEventProvider,
} from '@amazon-devices/kepler-epg-provider';

const onLogin = async (): Promise<void> => {
  try {
    // Schedule EPG Sync task with a given interval
    await EpgSyncTaskScheduler.scheduleTask(
      '<packageId>.epgSyncTask', // component id of the sync task
      60 * 24, // 24 hours in mins
    );
    console.info('EpgSync - EPG sync tasks are scheduled successfully!')
  } catch (error) {
    console.error(`EpgSync - Fail to schedule EPG Sync tasks due to ${error}`);
    throw error;
  }
};

const onLogout = async (): Promise<void> => {
  try {
    // Clear the customer’s existing channel lineup and live events
    await ChannelLineupProvider.add([]);
    await ChannelLineupProvider.commit("NO_VERSION");

    await LiveEventProvider.add([]);
    await LiveEventProvider.commit("NO_VERSION");

    // Cancel scheduled tasks
    EpgSyncTaskScheduler.cancelScheduledTasks();
    console.info('EpgSync - EPG sync tasks are removed successfully!')
  } catch (error) {
    console.error(`EpgSync - Clear EPG Sync failed due to ${error}`);
    throw error;
  }
};

When your onLogin() callback 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