Socket
Socket
Sign inDemoInstall

capacitor-detect-environment

Package Overview
Dependencies
2
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    capacitor-detect-environment

Detect Environment plugin for capacitor


Version published
Maintainers
1
Created

Readme

Source

Capacitor detect environment plugin .github/workflows/github-actions.yml

Plugin for determining the current environment

Currently only works on ios, but android support will be coming soon

Available methods:

  • isDebug()
  • isTestFlight()
  • isAdHoc()
  • isSimulator()
  • isAppStore()
  • isSandbox()

Usage example:

  1. In your module (e.g. app.module.ts)
...
import { DetectEnvironment } from 'capacitor-detect-environment'

@NgModule({
	...
	providers: [
		...
		DetectEnvironment,
	],
})
export class AppModule {}

  1. In your component or service (e.g. api.service.ts)
...
import { DetectEnvironment } from 'capacitor-detect-environment'

@Injectable()
export class ApiService {
	constructor(private env: DetectEnvironment) {}

    async getApiHost() {
        const isDebug = await this.env.isDebug()
        if (isDebug) return 'https://dev.api.com'
        else return 'https://api.com'
    }
}

BREAKING CHANGES in 1.x.x version

  • Added full support for Capacitor 3 and removed compatibility with Capacitor 2

Keywords

FAQs

Last updated on 02 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc