### Installation and Setup Source: https://capawesome.io/plugins/purchases Instructions for installing the Capacitor Purchases plugin and syncing native projects. ```APIDOC ## Installation and Setup ### Description Install the Capacitor Purchases plugin using npm and sync your native projects. ### Commands * **Install Plugin:** ```bash npm install @capawesome-team/capacitor-purchases ``` * **Sync Native Projects:** ```bash npx cap sync ``` ### Android Configuration #### Variables This plugin uses the following project variables (defined in your app's `variables.gradle` file): * `$googlePlayBillingVersion`: version of `com.android.billingclient:billing` (default: `8.2.0`) ### iOS Configuration #### Capabilities Ensure `In-App Purchase` capabilities have been enabled in your application in Xcode. See [Add a capability to a target](https://help.apple.com/xcode/mac/current/#/dev88ff319e7) for more information. ### General Configuration No additional configuration is required for this plugin. ``` -------------------------------- ### Install @capawesome/capacitor-libsql Source: https://capawesome.io/plugins/libsql/index Installs the @capawesome/capacitor-libsql plugin and synchronizes native project files. This is the initial setup step for using the plugin in a Capacitor project. ```bash npm install @capawesome/capacitor-libsql npx cap sync ``` -------------------------------- ### Install Capacitor Purchases Plugin Source: https://capawesome.io/plugins/purchases Installs the @capawesome-team/capacitor-purchases package and syncs Capacitor platform files. This is the initial setup step for using the plugin. ```bash npm install @capawesome-team/capacitor-purchases npx cap sync ``` -------------------------------- ### Install and Sync Capawesome Insider Plugin Source: https://capawesome.io/insiders/getting-started/index Install an Insider plugin from the Capawesome private registry using npm and then synchronize your Capacitor project. Replace `` with the desired plugin, for example, `capacitor-nfc`. ```bash npm install @capawesome-team/ npx cap sync ``` ```bash npm install @capawesome-team/capacitor-nfc npx cap sync ``` -------------------------------- ### Install @capawesome/capacitor-file-picker Source: https://capawesome.io/plugins/file-picker/index Installs the @capawesome/capacitor-file-picker plugin using npm and synchronizes Capacitor plugins. This is the initial setup step for using the file picker functionality. ```bash npm install @capawesome/capacitor-file-picker npx cap sync ``` -------------------------------- ### Install and Sync @capawesome/capacitor-app-review Source: https://capawesome.io/plugins/app-review/index Installs the @capawesome/capacitor-app-review package using npm and synchronizes Capacitor plugins. This is the initial setup step for using the app review functionality. ```bash npm install @capawesome/capacitor-app-review npx cap sync ``` -------------------------------- ### Install @capawesome/capacitor-posthog Plugin Source: https://capawesome.io/plugins/posthog/index Installs the PostHog Capacitor plugin and synchronizes native dependencies. This is the initial setup step for integrating PostHog into a Capacitor project. ```bash npm install @capawesome/capacitor-posthog posthog-js npx cap sync ``` -------------------------------- ### Install Barcode Scanning Plugin Source: https://capawesome.io/blog/announcing-the-capacitor-mlkit-barcode-scanner-plugin Installs the barcode scanning plugin and syncs the Capacitor project. This is the initial setup step for using the plugin. ```bash npm install @capacitor-mlkit/barcode-scanning npx cap sync ``` -------------------------------- ### Installation Source: https://capawesome.io/plugins/firebase/cloud-messaging Install the plugin and its dependencies using npm and sync with Capacitor. ```APIDOC ## Installation ```bash npm install @capacitor-firebase/messaging firebase npx cap sync ``` Add Firebase to your project if you haven't already ([Android](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#android) / [iOS](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#ios) / [Web](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#web)). ``` -------------------------------- ### Install @capawesome/capacitor-live-update Plugin Source: https://capawesome.io/plugins/live-update/index Installs the @capawesome/capacitor-live-update plugin using npm and synchronizes Capacitor native projects. This is the initial setup step for enabling live updates. ```bash npm install @capawesome/capacitor-live-update npx cap sync ``` -------------------------------- ### Install @capawesome/capacitor-managed-configurations Source: https://capawesome.io/plugins/managed-configurations/index Installs the @capawesome/capacitor-managed-configurations plugin using npm and synchronizes native project files with npx cap sync. This is the initial setup step for using the plugin. ```bash npm install @capawesome/capacitor-managed-configurations npx cap sync ``` -------------------------------- ### Install and Sync Capacitor Torch Plugin Source: https://capawesome.io/plugins/torch/index Installs the @capawesome/capacitor-torch plugin using npm and synchronizes native project files with npx cap sync. This is the initial setup step for using the plugin. ```bash npm install @capawesome/capacitor-torch npx cap sync ``` -------------------------------- ### Install and Sync Capacitor Background Task Plugin Source: https://capawesome.io/plugins/background-task/index Installs the @capawesome/capacitor-background-task plugin using npm and synchronizes Capacitor plugins with the native projects. This is the initial setup step for using the plugin. ```bash npm install @capawesome/capacitor-background-task npx cap sync ``` -------------------------------- ### Install Capacitor ML Kit Selfie Segmentation Plugin Source: https://capawesome.io/plugins/mlkit/selfie-segmentation/index Installs the @capacitor-mlkit/selfie-segmentation package using npm and synchronizes Capacitor plugins. This is the initial setup step for using the plugin. ```bash npm install @capacitor-mlkit/selfie-segmentation npx cap sync ``` -------------------------------- ### Complete GitHub Actions Workflow Example with Capawesome Packages Source: https://capawesome.io/insiders/integrations/github-actions/index An example of a full GitHub Actions workflow that checks out code, sets up Node.js, configures the Capawesome npm registry, installs dependencies, syncs Capacitor, and builds web assets, enabling the use of private Capawesome packages. ```yaml name: Build App on: push: branches: - main pull_request: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Node.js 20 uses: actions/setup-node@v4 with: node-version: 20 - name: Configure the Capawesome npm registry run: | echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc echo "//npm.registry.capawesome.io/:_authToken=${{ secrets.CAPAWESOME_NPM_REGISTRY_TOKEN }}" >> .npmrc - name: Install Dependencies run: npm ci - name: Sync Capacitor run: npx cap sync - name: Build web assets run: npm run build ``` -------------------------------- ### Install @capawesome/capacitor-cloudinary Plugin Source: https://capawesome.io/plugins/cloudinary/index Installs the @capawesome/capacitor-cloudinary plugin using npm and synchronizes Capacitor plugins. This is the initial setup step for using the Cloudinary plugin in a Capacitor project. ```bash npm install @capawesome/capacitor-cloudinary npx cap sync ``` -------------------------------- ### Install and Sync Capacitor Superwall Plugin Source: https://capawesome.io/plugins/superwall/index Installs the Superwall Capacitor plugin using npm and synchronizes native project files with the npx cap sync command. This is the initial setup step for integrating the plugin. ```bash npm install @capawesome/capacitor-superwall npx cap sync ``` -------------------------------- ### Capacitor Barometer Plugin Usage Examples (JavaScript/TypeScript) Source: https://capawesome.io/plugins/barometer/index Demonstrates how to use the Capacitor Barometer plugin in a web application. Includes examples for getting a single measurement, checking availability, starting/stopping real-time updates, and managing permissions. ```typescript import { Barometer } from '@capawesome-team/capacitor-barometer'; const getMeasurement = async () => { const { measurement } = await Barometer.getMeasurement(); console.log('Pressure:', measurement.pressure, 'hPa'); console.log('Relative Altitude:', measurement.relativeAltitude, 'm'); console.log('Timestamp:', new Date(measurement.timestamp)); }; const isAvailable = async () => { const result = await Barometer.isAvailable(); console.log('Barometer is available:', result.isAvailable); }; const startMeasurementUpdates = async () => { Barometer.addListener('measurement', (event) => { console.log('New measurement:', event); }); await Barometer.startMeasurementUpdates(); }; const stopMeasurementUpdates = async () => { await Barometer.stopMeasurementUpdates(); Barometer.removeAllListeners(); }; const checkPermissions = async () => { const status = await Barometer.checkPermissions(); console.log('Barometer permission status:', status.barometer); }; const requestPermissions = async () => { const status = await Barometer.requestPermissions(); console.log('Barometer permission status after request:', status.barometer); }; ``` -------------------------------- ### Complete Bitbucket Pipeline Example for Building Ionic App with Capawesome Packages Source: https://capawesome.io/insiders/integrations/bitbucket-pipelines/index A full `bitbucket-pipelines.yml` example demonstrating how to build an Ionic application that utilizes private Capawesome npm packages. It includes setting up the npm registry, installing dependencies, syncing Capacitor, building the app, and defining artifacts. ```yaml image: node:20 pipelines: default: - step: name: Build App caches: - node script: - echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc - echo "//npm.registry.capawesome.io/:_authToken=${CAPAWESOME_NPM_REGISTRY_TOKEN}" >> .npmrc - npm ci - npx cap sync - npm run build artifacts: - dist/** ``` -------------------------------- ### Complete GitLab CI/CD Pipeline Example with Capawesome Packages Source: https://capawesome.io/insiders/integrations/gitlab-ci/index An example GitLab CI/CD pipeline that builds an Ionic app. It configures the Capawesome npm registry, installs dependencies, syncs Capacitor, builds the app, and defines artifacts and rules. ```yaml stages: - build build-app: stage: build image: node:20 before_script: - echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc - echo "//npm.registry.capawesome.io/:_authToken=${CAPAWESOME_NPM_REGISTRY_TOKEN}" >> .npmrc - npm ci script: - npx cap sync - npm run build artifacts: paths: - dist/ expire_in: 1 hour rules: - if: $CI_COMMIT_BRANCH == "main" - if: $CI_PIPELINE_SOURCE == "merge_request_event" ``` -------------------------------- ### Install @capawesome/capacitor-photo-editor Source: https://capawesome.io/plugins/photo-editor/index Installs the @capawesome/capacitor-photo-editor plugin using npm and synchronizes Capacitor plugins. Ensure you have Node.js and npm installed. ```bash npm install @capawesome/capacitor-photo-editor npx cap sync ``` -------------------------------- ### Setup API Source: https://capawesome.io/plugins/posthog Sets up the PostHog SDK with the provided options. This method should be called before any other method. ```APIDOC ## POST /setup ### Description Setup the PostHog SDK with the provided options. This method should be called before any other method. Alternatively, on Android and iOS, you can configure this plugin in your Capacitor Configuration file. In this case, you must not call this method. ### Method POST ### Endpoint /setup ### Parameters #### Request Body - **options** (SetupOptions) - Required - Configuration options for the PostHog SDK. ### Request Example ```json { "apiKey": "YOUR_API_KEY", "host": "https://app.posthog.com" } ``` ### Response #### Success Response (200) - **message** (string) - Indicates successful setup. #### Response Example ```json { "message": "PostHog SDK setup successfully." } ``` ``` -------------------------------- ### Install Capawesome Capacitor Live Update Plugin Source: https://capawesome.io/cloud/live-updates/setup/index Installs the latest version of the Capawesome Capacitor Live Update plugin using npm. This is a prerequisite for enabling live updates in the Capacitor app. ```bash npm install @capawesome/capacitor-live-update@latest ``` -------------------------------- ### Import and Use Capawesome Insider Plugin (NFC Example) Source: https://capawesome.io/insiders/getting-started/index Import a Capawesome Insider plugin into your TypeScript/JavaScript code and demonstrate its basic usage. This example shows how to import the `Nfc` class from `@capawesome-team/capacitor-nfc` and check if NFC is supported. ```typescript import { Nfc } from '@capawesome-team/capacitor-nfc'; // Start using the plugin const result = await Nfc.isSupported(); console.log('NFC supported:', result.isSupported); ``` -------------------------------- ### Complete Jenkins Pipeline Example with Capawesome Packages Source: https://capawesome.io/insiders/integrations/jenkins/index A full Jenkins pipeline example demonstrating the setup of Node.js, configuration of the Capawesome npm registry, installation of dependencies, and building an Ionic app using private Capawesome packages. It includes a post-build step to clean up the .npmrc file. ```groovy pipeline { agent any environment { NODE_VERSION = '20' } stages { stage('Setup') { steps { // Install Node.js sh ''' curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | sudo -E bash - sudo apt-get install -y nodejs ''' } } stage('Configure Registry') { steps { withCredentials([string(credentialsId: 'CAPAWESOME_NPM_REGISTRY_TOKEN', variable: 'CAPAWESOME_NPM_REGISTRY_TOKEN')]) { sh ''' echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc echo "//npm.registry.capawesome.io/:_authToken=${CAPAWESOME_NPM_REGISTRY_TOKEN}" >> .npmrc ''' } } } stage('Install Dependencies') { steps { sh 'npm ci' } } stage('Build') { steps { sh ''' npx cap sync npm run build ''' } } } post { always { // Clean up .npmrc file sh 'rm -f .npmrc' } } } ``` -------------------------------- ### Capacitor Speech Recognition Plugin Usage Examples (JavaScript/TypeScript) Source: https://capawesome.io/plugins/speech-recognition This snippet provides examples of how to use the Capacitor Speech Recognition plugin in JavaScript or TypeScript. It demonstrates starting and stopping listening, checking and requesting permissions, verifying availability and listening status, getting supported languages, and adding/removing event listeners. ```javascript import { SpeechRecognition } from '@capawesome-team/capacitor-speech-recognition'; const startListening = async () => { await SpeechRecognition.startListening({ language: 'en-US', silenceThreshold: 2000, }); }; const stopListening = async () => { await SpeechRecognition.stopListening(); }; const checkPermissions = async () => { const { audioRecording, speechRecognition } = await SpeechRecognition.checkPermissions(); }; const requestPermissions = async () => { const { audioRecording, speechRecognition } = await SpeechRecognition.requestPermissions({ permissions: ['audioRecording', 'speechRecognition'], }); }; const isAvailable = async () => { const { isAvailable } = await SpeechRecognition.isAvailable(); return isAvailable; }; const isListening = async () => { const { isListening } = await SpeechRecognition.isListening(); return isListening; }; const getLanguages = async () => { const { languages } = await SpeechRecognition.getLanguages(); return languages; }; const addListeners = () => { SpeechRecognition.addListener('start', () => { console.log('Speech recognition started'); }); SpeechRecognition.addListener('end', () => { console.log('Speech recognition ended'); }); SpeechRecognition.addListener('error', (event) => { console.error('Speech recognition error:', event.message); }); SpeechRecognition.addListener('partialResult', (event) => { console.log('Partial result:', event.result); }); SpeechRecognition.addListener('result', (event) => { console.log('Final result:', event.result); }); SpeechRecognition.addListener('soundLevel', (event) => { console.log('Sound level:', event.level); }); SpeechRecognition.addListener('speechStart', () => { console.log('User started speaking'); }); SpeechRecognition.addListener('speechEnd', () => { console.log('User stopped speaking'); }); }; const removeAllListeners = async () => { await SpeechRecognition.removeAllListeners(); }; ``` -------------------------------- ### Install Capawesome NPM Registry and Plugin Source: https://capawesome.io/plugins/purchases/index Sets up the Capawesome npm registry and installs the @capawesome-team/capacitor-purchases plugin. Requires a license key for access. Ensure you replace `` with your actual key. ```bash npm config set @capawesome-team:registry https://npm.registry.capawesome.io npm config set //npm.registry.capawesome.io/:_authToken npm install @capawesome-team/capacitor-purchases npx cap sync ``` -------------------------------- ### Implement Live Update Logic (Always Latest) Source: https://capawesome.io/cloud/live-updates/setup-capacitor-6/index Implements the 'Always Latest' update strategy for Capawesome Live Updates. This JavaScript code listens for the app resume event, checks for updates, and prompts the user to install. ```javascript import { App } from "@capacitor/app"; import { LiveUpdate } from "@capawesome/capacitor-live-update"; App.addListener("resume", async () => { const { nextBundleId } = await LiveUpdate.sync(); if (nextBundleId) { // Ask the user if they want to apply the update immediately const shouldReload = confirm("A new update is available. Would you like to install it?"); if (shouldReload) { await LiveUpdate.reload(); } } }); ``` -------------------------------- ### Install Capacitor Wifi Plugin Source: https://capawesome.io/plugins/wifi/index Installs the @capawesome-team/capacitor-wifi package and synchronizes native projects. ```bash npm install @capawesome-team/capacitor-wifi npx cap sync ``` -------------------------------- ### SetupOptions Source: https://capawesome.io/plugins/posthog/index Configuration options for initializing the PostHog client. ```APIDOC ## SetupOptions ### Description Configuration options for initializing the PostHog client. ### Parameters #### Request Body - **`apiKey`** (string) - Required - The API key of your PostHog project. - **`cookielessMode`** (string) - Optional - Cookieless tracking mode. Options: `'always'`, `'on_reject'`. Requires cookieless mode to be enabled in PostHog project settings. - **`enableSessionReplay`** (boolean) - Optional - Whether to enable session recording automatically. Defaults to `false`. - **`host`** (string) - Optional - The host of your PostHog instance. Defaults to `'https://us.i.posthog.com'`. - **`optOut`** (boolean) - Optional - Whether to opt out of capturing by default. Defaults to `false`. - **`sessionReplayConfig`** (SessionReplayOptions) - Optional - Session replay configuration options. ### Request Example ```json { "apiKey": "YOUR_API_KEY", "host": "https://your.posthog.host.com", "enableSessionReplay": true } ``` ### Response #### Success Response (200) This endpoint does not return a response body. Configuration is applied internally. #### Response Example ```json { "message": "Configuration applied successfully." } ``` ``` -------------------------------- ### Install Capacitor Accelerometer Plugin Source: https://capawesome.io/plugins/accelerometer/index Commands to set up the Capawesome npm registry and install the accelerometer plugin. Requires a license key for Capawesome Insiders. ```bash npm config set @capawesome-team:registry https://npm.registry.capawesome.io npm config set //npm.registry.capawesome.io/:_authToken npm install @capawesome-team/capacitor-accelerometer npx cap sync ``` -------------------------------- ### Live Update Plugin Usage Examples Source: https://capawesome.io/plugins/live-update/index This section provides various JavaScript examples for interacting with the Capacitor Live Update plugin. It covers functions for managing bundles, channels, and application state. ```javascript import { LiveUpdate } from '@capawesome/capacitor-live-update'; const deleteBundle = async () => { await LiveUpdate.deleteBundle({ bundleId: 'my-bundle' }); }; const downloadBundle = async () => { await LiveUpdate.downloadBundle({ url: 'https://example.com/1.0.0.zip', bundleId: '1.0.0' }); }; const fetchLatestBundle = async () => { await LiveUpdate.fetchLatestBundle(); }; const getBundles = async () => { const result = await LiveUpdate.getBundles(); return result.bundleIds; }; const getChannel = async () => { const result = await LiveUpdate.getChannel(); return result.channel; }; const getCurrentBundle = async () => { const result = await LiveUpdate.getCurrentBundle(); return result.bundleId; }; const getCustomId = async () => { const result = await LiveUpdate.getCustomId(); return result.customId; }; const getDeviceId = async () => { const result = await LiveUpdate.getDeviceId(); return result.deviceId; }; const getNextBundle = async () => { const result = await LiveUpdate.getNextBundle(); return result.bundleId; }; const getVersionCode = async () => { const result = await LiveUpdate.getVersionCode(); return result.versionCode; }; const getVersionName = async () => { const result = await LiveUpdate.getVersionName(); return result.versionName; }; const ready = async () => { const result = await LiveUpdate.ready(); if (result.currentBundleId) { console.log(`The app is now using the bundle with the identifier ${result.currentBundleId}.`); } if (result.previousBundleId) { console.log(`The app was using the bundle with the identifier ${result.previousBundleId}.`); } if (result.rollback) { console.log('The app was reset to the default bundle.'); } }; const reload = async () => { await LiveUpdate.reload(); }; const reset = async () => { await LiveUpdate.reset(); }; const setChannel = async () => { await LiveUpdate.setChannel({ channel: 'production-5' }); }; const setCustomId = async () => { await LiveUpdate.setCustomId({ customId: 'my-custom-id' }); }; const setNextBundle = async () => { await LiveUpdate.setNextBundle({ bundleId: '7f0b9bf2-dff6-4be2-bcac-b068cc5ea756' }); }; const sync = async () => { const result = await LiveUpdate.sync({ channel: 'production-5', }); return result.nextBundleId; }; const isNewBundleAvailable = async () => { const { bundleId: latestBundleId } = await LiveUpdate.fetchLatestBundle({ channel: 'production-5', }); if (latestBundleId) { const { bundleId: currentBundleId } = await LiveUpdate.getCurrentBundle(); return latestBundleId !== currentBundleId; } else { return false; } }; ``` -------------------------------- ### Setup PostHog SDK Source: https://capawesome.io/plugins/posthog/index Initializes the PostHog SDK with the provided configuration options. This method must be called before any other SDK method. Alternatively, configuration can be done in the Capacitor Configuration file for Android and iOS. Returns a Promise. Available since version 6.0.0. ```typescript setup(options: SetupOptions) => Promise ``` -------------------------------- ### Install @capawesome/capacitor-badge Source: https://capawesome.io/plugins/badge/index Installs the @capawesome/capacitor-badge plugin using npm and synchronizes Capacitor native projects. This is the initial setup step for using the badge functionality. ```bash npm install @capawesome/capacitor-badge npx cap sync ``` -------------------------------- ### Install Capacitor File Opener Plugin Source: https://capawesome.io/plugins/file-opener/index Installs the Capacitor File Opener plugin using npm and synchronizes native project files with npx cap sync. This is the initial step for integrating the plugin into a Capacitor project. ```bash npm install @capawesome-team/capacitor-file-opener npx cap sync ``` -------------------------------- ### apps:builds:create Source: https://capawesome.io/cloud/cli/index Create a new app build. ```APIDOC ## POST /apps/{appId}/builds ### Description Create a new app build. ### Method POST ### Endpoint /apps/{appId}/builds ### Parameters #### Path Parameters - **appId** (string) - Required - The ID of the app to create the build for. #### Query Parameters - **aab** (string) - Optional - Download the generated AAB file (Android only). Optionally provide a file path. - **apk** (string) - Optional - Download the generated APK file (Android only). Optionally provide a file path. - **certificate** (string) - Optional - The name of the certificate to use for the build. - **detached** (boolean) - Optional - Exit immediately after creating the build without waiting for completion. - **environment** (string) - Optional - The name of the environment to use for the build. - **git-ref** (string) - Optional - The Git reference (branch, tag, or commit SHA) to build. - **ipa** (string) - Optional - Download the generated IPA file (iOS only). Optionally provide a file path. - **json** (boolean) - Optional - Output in JSON format. This will include additional information such as the build ID. - **platform** (string) - Required - The platform for the build. Supported values are `android`, `ios`, and `web`. - **stack** (string) - Required - The name of the stack to use for the build. Must be either `macos-sequoia` or `macos-tahoe`. - **type** (string) - Optional - The type of build. For Android, supported values are `debug` and `release`. For iOS, supported values are `simulator`, `development`, `ad-hoc`, `app-store`, and `enterprise`. For Web, no type is required. - **yes** (boolean) - Optional - Skip confirmation prompts. - **zip** (string) - Optional - Download the generated zip file (Web only). Optionally provide a file path. ### Request Example ```bash npx @capawesome/cli apps:builds:create --app-id "app_abc" --platform "ios" --git-ref "main" --stack "macos-sequoia" --type "app-store" ``` ### Response #### Success Response (201) - **id** (string) - The ID of the newly created build. - **status** (string) - The status of the build. - **appId** (string) - The ID of the app the build belongs to. #### Response Example ```json { "id": "build_xyz", "status": "pending", "appId": "app_abc" } ``` ``` -------------------------------- ### Install Capacitor Barometer Plugin Source: https://capawesome.io/plugins/barometer/index Commands to set up the Capawesome npm registry and install the Capacitor Barometer plugin. Requires a license key for Capawesome Insiders. ```bash npm config set @capawesome-team:registry https://npm.registry.capawesome.io npm config set //npm.registry.capawesome.io/:_authToken npm install @capawesome-team/capacitor-barometer npx cap sync ``` -------------------------------- ### Install Capacitor Audio Player Plugin Source: https://capawesome.io/plugins/audio-player/index Commands to configure npm registry and install the audio player plugin. Requires a license key for Capawesome Insiders. ```bash npm config set @capawesome-team:registry https://npm.registry.capawesome.io npm config set //npm.registry.capawesome.io/:_authToken npm install @capawesome-team/capacitor-audio-player npx cap sync ``` -------------------------------- ### Install Capacitor File Compressor Source: https://capawesome.io/plugins/file-compressor/index Commands to set up the Capawesome npm registry and install the Capacitor File Compressor package. Requires a license key for access. ```bash npm config set @capawesome-team:registry https://npm.registry.capawesome.io npm config set //npm.registry.capawesome.io/:_authToken npm install @capawesome-team/capacitor-file-compressor npx cap sync ``` -------------------------------- ### List Provisioning Profiles Locally (Bash) Source: https://capawesome.io/cloud/native-builds/certificates/ios/index This command lists all installed provisioning profiles on a Mac and displays their details, including name, application identifier, and expiration date. It requires access to the Terminal and the security command-line tool. ```bash for f in ~/Library/MobileDevice/Provisioning\ Profiles/*.mobileprovision; do echo "=== $f ==="; security cms -D -i "$f" 2>/dev/null | grep -A 1 'application-identifier\|Name\|ExpirationDate' | grep -v '^--$'; echo; done ``` -------------------------------- ### Complete Azure Pipelines YAML Example for Ionic App Build Source: https://capawesome.io/insiders/integrations/azure-devops/index This YAML configuration demonstrates a full Azure Pipeline setup for building an Ionic application that utilizes private Capawesome npm packages. It includes steps for checking out code, setting up Node.js, configuring the npm registry, installing dependencies, syncing Capacitor, building the app, and publishing artifacts. ```yaml trigger: - main pool: vmImage: ubuntu-latest variables: - name: nodeVersion value: '20.x' jobs: - job: Build displayName: Build App steps: - checkout: self displayName: Checkout Repository - task: UseNode@1 inputs: version: $(nodeVersion) displayName: Setup Node.js $(nodeVersion) - script: echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc displayName: Configure Capawesome npm registry - script: echo "//npm.registry.capawesome.io/:_authToken=$(CAPAWESOME_NPM_REGISTRY_TOKEN)" >> .npmrc displayName: Authenticate with Capawesome registry - script: npm ci displayName: Install Dependencies - script: npx cap sync displayName: Sync Capacitor - script: npm run build displayName: Build App - task: PublishBuildArtifacts@1 inputs: pathtoPublish: 'dist' artifactName: 'build-output' displayName: Publish Build Artifacts ``` -------------------------------- ### Capacitor Live Update Plugin Usage Examples (TypeScript) Source: https://capawesome.io/plugins/live-update This TypeScript code demonstrates various methods provided by the Capacitor Live Update plugin. It covers functionalities such as deleting bundles, downloading new bundles, fetching the latest updates, and retrieving information about installed and available bundles. These examples require the `@capawesome/capacitor-live-update` package to be installed. ```typescript import { LiveUpdate } from '@capawesome/capacitor-live-update'; const deleteBundle = async () => { await LiveUpdate.deleteBundle({ bundleId: 'my-bundle' }); }; const downloadBundle = async () => { await LiveUpdate.downloadBundle({ url: 'https://example.com/1.0.0.zip', bundleId: '1.0.0' }); }; const fetchLatestBundle = async () => { await LiveUpdate.fetchLatestBundle(); }; const getBundles = async () => { const result = await LiveUpdate.getBundles(); return result.bundleIds; }; const getChannel = async () => { const result = await LiveUpdate.getChannel(); return result.channel; }; const getCurrentBundle = async () => { const result = await LiveUpdate.getCurrentBundle(); return result.bundleId; }; const getCustomId = async () => { const result = await LiveUpdate.getCustomId(); return result.customId; }; const getDeviceId = async () => { const result = await LiveUpdate.getDeviceId(); return result.deviceId; }; const getNextBundle = async () => { const result = await LiveUpdate.getNextBundle(); return result.bundleId; }; const getVersionCode = async () => { const result = await LiveUpdate.getVersionCode(); return result.versionCode; }; const getVersionName = async () => { const result = await LiveUpdate.getVersionName(); return result.versionName; }; const ready = async () => { ``` -------------------------------- ### Usage Examples Source: https://capawesome.io/plugins/purchases Code examples demonstrating how to use the Capacitor Purchases API for purchasing products and restoring purchases. ```APIDOC ## Usage Examples ### Description Examples of how to use the Capacitor Purchases plugin to handle product purchases and restore existing purchases. ### Import ```typescript import { Purchases } from '@capawesome-team/capacitor-purchases'; ``` ### Purchase Product ```typescript const purchaseProduct = async (productId: string) => { const { transaction } = await Purchases.purchaseProduct({ productId }); // Deliver the purchased content or enable the service here // ... // Finish the transaction await Purchases.finishTransaction({ transactionId: transaction.id }); }; ``` ### Restore Purchases ```typescript const restorePurchases = async () => { await Purchases.syncTransactions(); const { transactions } = await Purchases.getCurrentTransactions(); for (const transaction of transactions) { // Deliver the purchased content or enable the service here // ... } }; ``` ``` -------------------------------- ### Install @capawesome-team/capacitor-share-target Plugin Source: https://capawesome.io/plugins/share-target/index Installs the share target plugin and synchronizes native project files. This command should be run after configuring the npm registry. ```bash npm install @capawesome-team/capacitor-share-target npx cap sync ``` -------------------------------- ### Install Ionic CLI Source: https://capawesome.io/blog/how-to-build-a-heart-rate-monitor-with-capacitor Installs the Ionic Command Line Interface globally, which is necessary for creating and managing Ionic projects. ```bash npm install -g @ionic/cli ``` -------------------------------- ### Install Google Barcode Scanner Module Source: https://capawesome.io/plugins/mlkit/barcode-scanning/index Initiates the installation process for the Google Barcode Scanner module on Android devices. Note that this action only starts the installation; the `googleBarcodeScannerModuleInstallProgress` event will signal completion. This function is available since version 5.1.0. ```typescript installGoogleBarcodeScannerModule() => Promise ``` -------------------------------- ### Install Google Subject Segmentation Module in TypeScript Source: https://capawesome.io/plugins/mlkit/subject-segmentation/index Initiates the installation of the Google Subject Segmentation module. This function only starts the process; progress and completion are notified via the 'googleSubjectSegmentationModuleInstallProgress' event listener. Only available on Android. ```typescript import { SubjectSegmentation } from '@capacitor-mlkit/subject-segmentation'; await SubjectSegmentation.installGoogleSubjectSegmentationModule(); ``` -------------------------------- ### Copy Provisioning Profile Locally (Bash) Source: https://capawesome.io/cloud/native-builds/certificates/ios/index This command copies a specified provisioning profile file from the user's Mobile Device provisioning profiles directory to the Desktop. Replace `` with the actual UUID of the profile you wish to copy. This is useful for preparing profiles for upload. ```bash cp ~/Library/MobileDevice/Provisioning\ Profiles/.mobileprovision ~/Desktop/ ``` -------------------------------- ### Start BLE Characteristic Notifications Source: https://capawesome.io/plugins/bluetooth-low-energy/index Starts listening for changes in a BLE characteristic's value. This function is available on Android and iOS and emits a `characteristicChanged` event when a value changes. It returns a Promise that resolves upon successful setup. ```typescript startCharacteristicNotifications(options: StartCharacteristicNotificationsOptions) => Promise ``` -------------------------------- ### Setup PostHog SDK Source: https://capawesome.io/plugins/posthog Initializes the PostHog SDK with the specified configuration options. This method must be called before any other SDK method. Alternatively, configuration can be done via the Capacitor Configuration file on Android and iOS. Requires SetupOptions. Available since version 6.0.0. ```typescript setup(options: SetupOptions): Promise ``` -------------------------------- ### Capacitor Pedometer Plugin Usage Examples Source: https://capawesome.io/plugins/pedometer/index TypeScript examples demonstrating how to use the Capacitor Pedometer plugin's API, including getting measurements, checking availability, starting/stopping updates, and managing permissions. ```typescript import { Pedometer } from '@capawesome-team/capacitor-pedometer'; const getMeasurement = async () => { const { measurement } = await Pedometer.getMeasurement(); console.log(measurement); }; const isAvailable = async () => { const { cadence, distance, floorCounting, pace, stepCounting } = await Pedometer.isAvailable(); console.log('Cadence available:', cadence); console.log('Distance available:', distance); console.log('Floor counting available:', floorCounting); console.log('Pace available:', pace); console.log('Step counting available:', stepCounting); }; const startMeasurementUpdates = async () => { Pedometer.addListener('measurement', (event) => { console.log('New measurement:', event); }); await Pedometer.startMeasurementUpdates(); }; const stopMeasurementUpdates = async () => { await Pedometer.stopMeasurementUpdates(); }; const checkPermissions = async () => { const status = await Pedometer.checkPermissions(); console.log('Permission status:', status); }; const requestPermissions = async () => { const status = await Pedometer.requestPermissions(); console.log('Permission status after request:', status); }; ``` -------------------------------- ### Install Capacitor Media Session Plugin Source: https://capawesome.io/plugins/media-session/index Installs the @capawesome-team/capacitor-media-session package and synchronizes native projects. Ensure the Capawesome NPM registry is configured first. ```bash npm install @capawesome-team/capacitor-media-session npx cap sync ``` -------------------------------- ### Install Capacitor Firebase Cloud Firestore Plugin Source: https://capawesome.io/blog/announcing-the-capacitor-firebase-cloud-firestore-plugin Commands to install the Capacitor Firebase Cloud Firestore plugin and synchronize native project files. Requires prior Firebase project setup. ```bash npm install @capacitor-firebase/firestore npx cap sync ``` -------------------------------- ### Usage of Capacitor ML Kit Document Scanner Source: https://capawesome.io/plugins/mlkit/document-scanner/index Demonstrates how to use the DocumentScanner API from the @capacitor-mlkit/document-scanner plugin. It includes functions for scanning documents with various options, checking if the Google Document Scanner module is available, installing the module, and listening for installation progress. These examples are primarily for JavaScript/TypeScript environments. ```typescript import { DocumentScanner } from '@capacitor-mlkit/document-scanner'; const scanDocument = async () => { const result = await DocumentScanner.scanDocument({ galleryImportAllowed: true, pageLimit: 5, resultFormats: 'JPEG_PDF', scannerMode: 'FULL', }); console.log('Scanned images:', result.scannedImages); console.log('PDF info:', result.pdf); }; const isGoogleDocumentScannerModuleAvailable = async () => { const result = await DocumentScanner.isGoogleDocumentScannerModuleAvailable(); console.log('Is Google Document Scanner module available:', result.available); }; const installGoogleDocumentScannerModule = async () => { await DocumentScanner.installGoogleDocumentScannerModule(); console.log('Google Document Scanner module installation started.'); }; DocumentScanner.addListener('googleDocumentScannerModuleInstallProgress', (event) => { console.log('Installation progress:', event.progress, '%'); console.log('Current state:', event.state); }); ``` -------------------------------- ### Automate App Store Deployment with GitHub Actions Source: https://cloud.capawesome.io/app-store-publishing This GitHub Actions workflow automates the process of building and deploying Capacitor apps to app stores. It checks out the code, builds the app using Capawesome CLI, and deploys it to the Google Play Store. It requires `CAPAWESOME_CLOUD_APP_ID` and `CAPAWESOME_CLOUD_TOKEN` secrets. ```yaml name: Deploy to Stores on: push: tags: - 'v*' jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Build app id: build run: | BUILD_ID=$(npx @capawesome/cli apps:builds:create \ --app-id ${{ secrets.CAPAWESOME_CLOUD_APP_ID }} \ --git-ref main \ --platform android \ --json | jq -r '.id') echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT env: CAPAWESOME_CLOUD_TOKEN: ${{ secrets.CAPAWESOME_CLOUD_TOKEN }} - name: Deploy to Google Play Store run: | npx @capawesome/cli apps:deployments:create \ --app-id ${{ secrets.CAPAWESOME_CLOUD_APP_ID }} \ --build-id ${{ steps.build.outputs.build_id }} \ --destination play-store env: CAPAWESOME_CLOUD_TOKEN: ${{ secrets.CAPAWESOME_CLOUD_TOKEN }} ``` -------------------------------- ### Capacitor Audio Recorder Plugin Setup and Usage Source: https://capawesome.io/plugins/audio-recorder This snippet demonstrates the basic setup and usage of the Capacitor Audio Recorder plugin. It includes installation commands and essential code for initializing and interacting with the audio recorder. Dependencies include Capacitor core libraries. ```bash npm install @capawesome/capacitor-audio-recorder npx cap sync ``` ```typescript import { AudioRecorder, RecordingState } from '@capawesome/capacitor-audio-recorder'; const startRecording = async () => { await AudioRecorder.start(); }; const stopRecording = async () => { const result = await AudioRecorder.stop(); console.log('Recording stopped:', result.value); }; const checkPermissions = async () => { const permissionState = await AudioRecorder.checkPermissions(); console.log('Permission state:', permissionState.value); }; const requestPermissions = async () => { await AudioRecorder.requestPermissions(); }; const getRecordingState = async () => { const state = await AudioRecorder.getCurrentState(); console.log('Recording state:', state.value); }; ``` -------------------------------- ### Starting Barcode Scan - Web Platform Source: https://capawesome.io/plugins/mlkit/barcode-scanning Illustrates how to start a barcode scan on the web platform using the Capacitor plugin. This might involve accessing the user's camera through the browser. ```typescript if (!isNative) { barcodeScanner.startScan(); } ``` -------------------------------- ### InitializeOptions Source: https://capawesome.io/plugins/sqlite/index Options for initializing the SQLite WebAssembly module. ```APIDOC ## InitializeOptions ### Description This object defines the options for initializing the SQLite WebAssembly module, particularly for web implementations. ### Request Body #### Fields - **`worker`** (Worker) - Required - The Worker to use for the SQLite WebAssembly initialization. If provided, this worker will be passed to the sqlite3Worker1Promiser method for initializing the SQLite WebAssembly module in the web implementation. Only available on Web. ### Request Example ```json { "worker": "" } ``` ``` -------------------------------- ### Capacitor Badge Plugin Usage Examples Source: https://capawesome.io/plugins/badge/index Demonstrates how to use the @capawesome/capacitor-badge plugin in TypeScript. Includes functions for getting, setting, increasing, decreasing, clearing badge counts, checking support, and managing permissions. ```typescript import { Badge } from '@capawesome/capacitor-badge'; const get = async () => { const result = await Badge.get(); return result.count; }; const set = async (count: number) => { await Badge.set({ count }); }; const increase = async () => { await Badge.increase(); }; const decrease = async () => { await Badge.decrease(); }; const clear = async () => { await Badge.clear(); }; const isSupported = async () => { const result = await Badge.isSupported(); return result.isSupported; }; const checkPermissions = async () => { const result = await Badge.checkPermissions(); }; const requestPermissions = async () => { const result = await Badge.requestPermissions(); }; ``` -------------------------------- ### Capacitor Accelerometer Plugin Usage (TypeScript) Source: https://capawesome.io/plugins/accelerometer/index Example TypeScript code demonstrating how to use the Capacitor Accelerometer plugin to get measurements, check availability, manage updates, and handle permissions. ```typescript import { Accelerometer } from '@capawesome-team/capacitor-accelerometer'; const getMeasurement = async () => { const measurement = await Accelerometer.getMeasurement(); console.log("X: ", measurement.x); console.log("Y: ", measurement.y); console.log("Z: ", measurement.z); }; const isAvailable = async () => { const result = await Accelerometer.isAvailable(); return result.isAvailable; }; const startMeasurementUpdates = async () => { await Accelerometer.startMeasurementUpdates(); }; const stopMeasurementUpdates = async () => { await Accelerometer.stopMeasurementUpdates(); }; const checkPermissions = async () => { const result = await Accelerometer.checkPermissions(); return result; }; const requestPermissions = async () => { const result = await Accelerometer.requestPermissions(); return result; }; const removeAllListeners = async () => { await Accelerometer.removeAllListeners(); }; ```