1.2.1 • Published 2 years ago

@robingenz/capacitor-badge v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Maintainers

MaintainerGitHubSocial
Robin Genzrobingenz@robin_genz

Installation

npm install @robingenz/capacitor-badge@next
npx cap sync

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Usage

import { Badge } from '@robingenz/capacitor-badge';

const get = async () => {
  const count = await Badge.get();
};

const set = async (count: number) => {
  await Badge.set({ count });
};

const clear = async () => {
  await Badge.clear();
};

API

get()

get() => Promise<GetBadgeResult>

Get the badge count. The badge count won't be lost after a reboot or app restart.

Default: 0.

Returns: Promise<GetBadgeResult>


set(...)

set(options: SetBadgeOptions) => Promise<void>

Set the badge count.

ParamType
optionsSetBadgeOptions

clear()

clear() => Promise<void>

Clear the badge count.


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Check permission to display badge.

Returns: Promise<PermissionStatus>


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Request permission to display badge.

Returns: Promise<PermissionStatus>


Interfaces

GetBadgeResult

PropType
countnumber

SetBadgeOptions

PropType
countnumber

PermissionStatus

PropTypeDescription
displayPermissionStatePermission state of displaying the badge.

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

Quirks

On Android not all launchers support badges. This plugin uses ShortcutBadger. All supported launchers are listed there.

Changelog

See CHANGELOG.md.

License

See LICENSE.