capacitor-detect-environment
v1.0.1
Published
Detect Environment plugin for capacitor
Downloads
13
Readme
Capacitor detect environment plugin
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:
- In your module (e.g.
app.module.ts
)
...
import { DetectEnvironment } from 'capacitor-detect-environment'
@NgModule({
...
providers: [
...
DetectEnvironment,
],
})
export class AppModule {}
- 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