Screen Time Guard Kit allows users to redirect from the intercept page of a managed app to the screen time guard app to adjust current guard strategies. Since version 26.0.0, Screen Time Guard Kit allows the want parameter to carry information about the current guard strategy during redirection.

The process is as follows:
When a managed app is unavailable due to an active guard strategy, a user taps the app. Digital Balance then displays the intercept page.
The user taps the redirect button at the bottom of the intercept page. Digital Balance queries the token of the managed app and the corresponding active guard strategies, and writes the strategy information to the custom parameters of want.
Digital Balance calls the startAbility API to start the screen time guard app, with the passed want parameter carrying information about the current guard strategies.
Your app receives and parses the want parameter in the onCreate and onNewWant callbacks of the entry ability to obtain information such as the tokens of the managed apps and names of active guard strategies.
The following table describes the custom parameters in want.
| Parameter | Type | Description |
|---|---|---|
| token | string | Token of the managed app. |
| strategyNames | string[] | Name of the active guard strategy for the managed app. If there are multiple guard strategies, an array of these strategy names is returned. |
| isSetAppsRestriction | boolean | Indicates whether an active strategy contains app access restrictions. true: yes. However, the names of these restrictions are not included in the strategyNames parameter. false: no |
User authorization is required for the intercept page to navigate to the screen time guard app and pass guard strategy information. Refer to Requesting User Authorization to complete the authorization process first.
Import required modules.
import { UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import Utils from '../utils/Utils'; Receive and parse the want parameter in onCreate and onNewWant to obtain the current guard strategy information.
export default class EntryAbility extends UIAbility {
// This callback is triggered when an UIAbility instance is created.
onCreate(want: Want): void {
hilog.info(0x0000, 'GuardService', 'onCreate');
let token: string = want.parameters?.['token'] as string;
if (token !== undefined) {
hilog.info(0x0000, 'GuardService', `Token: ${token}`);
}
let strategyNames: string[] = want.parameters?.['strategyNames'] as string[];
if (strategyNames !== undefined) {
hilog.info(0x0000, 'GuardService', `StrategyNames: ${strategyNames}`);
}
let isSetAppsRestriction: boolean = want.parameters?.['isSetAppsRestriction'] as boolean;
if (isSetAppsRestriction !== undefined) {
hilog.info(0x0000, 'GuardService', `IsSetAppsRestriction: ${isSetAppsRestriction}`);
}
}
// ...
// This callback is triggered when a started UIAbility instance is brought up again.
onNewWant(want: Want): void {
hilog.info(0x0000, 'GuardService', 'onNewWant');
let token: string = want.parameters?.['token'] as string;
if (token !== undefined) {
hilog.info(0x0000, 'GuardService', `Token: ${token}`);
}
let strategyNames: string[] = want.parameters?.['strategyNames'] as string[];
if (strategyNames !== undefined) {
hilog.info(0x0000, 'GuardService', `StrategyNames: ${strategyNames}`);
}
let isSetAppsRestriction: boolean = want.parameters?.['isSetAppsRestriction'] as boolean;
if (isSetAppsRestriction !== undefined) {
hilog.info(0x0000, 'GuardService', `IsSetAppsRestriction: ${isSetAppsRestriction}`);
}
}
// ...
}