The Plugins Client SDK provides many methods for several features in the Staffbase frontend application. Learn more about how the Plugins Client SDK works. This article lists the categories of methods and the individual methods that belong to those categories.
All methods return a Promise. If a call fails, the Promise rejects with an error message, so handle rejections in your plugin. Outside the Staffbase app, the SDK answers with built-in defaults instead.
Application context
These methods give information about the context of the environment in which the application is running.
| Method | Description |
|---|---|
| deviceCanDownload() | Checks if the user’s device can download a file |
| isIosDevice() | Checks if the user’s device is using iOS |
| isAndroidDevice() | Checks if the user’s device is using Android |
| getAppVersion() | Fetches the user’s app version |
| isNativeApp() | Checks if the plugin is running inside the native Staffbase app on iOS or Android If isNativeApp() returns true, isMobileApp() usually returns true as well. Both are detected independently, so don’t rely on one to infer the other. |
| isMobileApp() | Checks if the application is running on a mobile device, in a mobile browser or in the native app If the application is opened in a mobile browser, isMobileApp() returns true, but the isNativeApp() returns false |
| getInstanceUrl() | Fetches your Staffbase frontend application domain URL, for example https://customer.staffbase.com. Resolves to an empty string if the URL isn’t available Available since Plugins Client SDK 3.1.0 |
Language information
These methods give information about the languages of your organization and the user.
A language object has the shape { key, locale, name, localizedName }, for example { key: 'de', locale: 'de_DE', name: 'Deutsch', localizedName: 'German' }. name is the language’s own name, localizedName is its name in the user’s interface language. Right-to-left languages also carry direction: 'rtl'.
| Method | Description |
|---|---|
| getBranchLanguages() | Fetches all the content languages added for your organization, as an object keyed by language key, for example de or frCA, with a language object as each value |
| getBranchDefaultLanguage() | Fetches the default language configured for your organization, as a language object |
| getContentLanguages() | Fetches all the content languages supported by the Staffbase platform, in the same format as getBranchLanguages() |
| getUserContentLocale() | Fetches the locale saved in the user’s account, for example de_DE, and falls back to the default locale configured for your organization Available since Plugins Client SDK 3.0.0. Outside the Staffbase app, it resolves to undefined. |
| getPreferredContentLocale(content) | Fetches the locale to show from the locales a plugin has content for, and resolves to a locale string, for example de_DE. The optional content is either an array of locales, for example ['de_DE', 'en_US'], or an object keyed by locale, for example { de_DE: 'Hallo', en_US: 'Hello' }. The first match in this order wins:
Without content, it returns the user’s content locale if your organization has it enabled, otherwise the default locale. |
Action triggers
These are methods that trigger specific actions in the frontend application.
| Method | Description |
|---|---|
| openLink(url) | Opens a link depending on the frontend application logic. Links within your Staffbase app open inside the app. Other links open in the in-app browser on iOS, in the device browser on Android, and in a new tab in a web browser |
| openLinkExternal(url) | Opens a link in an external browser: the device browser in the native app, a new tab in a web browser |
| openLinkInternal(url) | Opens a link in an internal browser: the in-app browser in the native app, a new tab in a web browser All three methods accept links within your Staffbase app, which always open inside the app, and http or https URLs. They reject a missing URL and any other scheme. |
| openNativeShareDialog(content) | Opens the device’s share dialog: the native share sheet in the Staffbase app, the Web Share API in a web browser. content is an object with the optional fields url, image, subject, and text. url is shared as a link, or image as a link if url is empty. subject becomes the share title and text the shared text Fails if content is empty, or if the web browser doesn’t support the Web Share API. |
| openNativeFileDialog() | Opens a native file upload dialog and resolves to the selected image as a Blob Experimental. Only available in the native Staffbase app. Fails if the user cancels. |