In my understanding all the ionic native plugins should only work on a real device, or the browser when served via cordova run.
But I see, that the geolocation plugin works with ionic serve as well and I'm wondering now why and if this is possible with other plugins, file i.e as well.
An excerpt of my app.modules
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { Geolocation } from '@ionic-native/geolocation/ngx';
import { File } from '@ionic-native/file/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule],
providers: [
StatusBar,
File,
Geolocation,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
],
bootstrap: [AppComponent],
})
export class AppModule {}
How I call geolocation
import { Geolocation } from '@ionic-native/geolocation/ngx';
import { File } from '@ionic-native/file/ngx';
@Component({
selector: 'page-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage{
constructor(
private geolocation: Geolocation,
private file: File,
) {
this.geolocation.getCurrentPosition()
this.file.getFreeDiskSpace()
}
}