android-components / mozilla.components.feature.pwa / WebAppShortcutManager


class WebAppShortcutManager (source)

Helper to manage pinned shortcuts for websites.


httpClient - Fetch client used to load website icons.

storage - Storage used to save web app manifests to disk.

supportWebApps - If true, Progressive Web Apps will be pinnable. If false, all web sites will be bookmark shortcuts even if they have a manifest.


Name Summary
WebAppInstallState enum class WebAppInstallState
Possible install states of a Web App.


Name Summary
<init> WebAppShortcutManager(context: <ERROR CLASS>, httpClient: Client, storage: ManifestStorage, supportWebApps: Boolean = true)
Helper to manage pinned shortcuts for websites.


Name Summary
buildBasicShortcut suspend fun buildBasicShortcut(context: <ERROR CLASS>, session: Session, overrideShortcutName: String? = null): ShortcutInfoCompat
Create a new basic pinned website shortcut using info from the session. Consuming SHORTCUT_CATEGORY in AndroidManifest is required for the package to be launched
buildWebAppShortcut suspend fun buildWebAppShortcut(context: <ERROR CLASS>, manifest: WebAppManifest): ShortcutInfoCompat?
Create a new Progressive Web App shortcut using a web app manifest.
findShortcut fun findShortcut(context: <ERROR CLASS>, startUrl: String): Nothing?
Finds the shortcut associated with the given startUrl. This method can be used to check if a web app was added to the homescreen.
getWebAppInstallState suspend fun getWebAppInstallState(url: String, currentTimeMs: Long = System.currentTimeMillis()): WebAppInstallState
Checks if there is a currently installed web app to which this URL belongs.
recentlyUsedWebAppsCount suspend fun recentlyUsedWebAppsCount(activeThresholdMs: Long = ManifestStorage.ACTIVE_THRESHOLD_MS): Int
Counts number of recently used web apps. See ManifestStorage.activeThresholdMs.
reportWebAppUsed suspend fun reportWebAppUsed(manifest: WebAppManifest): Unit?
Updates the usedAt timestamp of the web app this url is associated with.
requestPinShortcut suspend fun requestPinShortcut(context: <ERROR CLASS>, session: Session, overrideShortcutName: String? = null): Unit
Request to create a new shortcut on the home screen.
updateShortcuts suspend fun updateShortcuts(context: <ERROR CLASS>, manifests: List<WebAppManifest>): Unit
Update existing PWA shortcuts with the latest info from web app manifests.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.