capacitor-detect-environment
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i capacitor-detect-environment

Weekly Downloads

5

Version

1.0.1

License

MIT

Unpacked Size

20.7 kB

Total Files

23

Last publish

Collaborators

  • rediska1114