@mica/sdk (SDK contract v1)
    Preparing search index...

    Function useControlCenter

    • Contribute this app's own switches to the control center (MICA-247). Requires the control-center permission.

      const cc = useControlCenter('radio');
      cc.registerToggle({
      id: 'scanner',
      label: 'Scanner',
      icon: 'MicrophoneIcon',
      active: get(scanning),
      onToggle: () => {
      scanning.update((on) => !on);
      cc.setToggleActive('scanner', get(scanning));
      }
      });

      The shell draws the switch; the app owns what it means. A tap calls onToggle and changes nothing on its own — the switch shows whatever the app last reported, so an app that refuses a tap simply does not call setToggleActive.

      What the shell holds a switch to, checked on the phone's side of the seam (a sandboxed add-on's arguments are whatever its script sent):

      • id is 1-32 letters, digits, - or _, unique within this app. Registering an id again replaces that switch.
      • label is 1-32 characters after trimming.
      • icon is the export name of an icon in @mica/sdk, such as 'MoonIcon'.
      • An app holds at most 3 switches at once; a fourth is refused, not rotated in.

      appId is this app's own id. For a core: false add-on the shell replaces it with the frame's own, so a frame cannot put a switch up under another app's name or reach another app's switches.

      Switches live as long as the component that registered them, like useSearchProvider: unmount takes them down, and an add-on's frame going away takes down every switch it holds whether or not its code got to run first. Apps are resident, so a switch registered from an app's root component stays up for the session — but only once the app has been opened; declare a preload if a switch must exist before that.

      A refused registration throws in-process and is logged from a sandboxed add-on, where the shell answers after this function has returned.

      Parameters

      • appId: string

      Returns ControlCenter