How to write data in firebase with Ionic?

Asked

Viewed 129 times

1

i have an application that displays on the screen the latitude and longitude wanted to know how to record this data in firebase

my home code is like this

import { Component } from '@angular/core';

import { Navcontroller, Platform } from 'Ionic-angular'; import { Geolocation, Geolocationoptions, Geoposition} from '@Ionic-Native/Geolocation';

@Component({ selector: 'page-home', templateUrl: 'home.html' }) export class Homepage{

geoposition: Geoposition

geolocationOptions: GeolocationOptions
    constructor(private platform: Platform, 
        private geolocation: Geolocation,
        public navCtrl: NavController){
        }

    async getGeolocation(){
        await this.platform.ready();

        try {

            this.geolocationOptions = {
                maximumAge: 1000,
                timeout: 1000,
                enableHighAccuracy: true
            }

            this.geoposition = await this.geolocation.getCurrentPosition(this.geolocationOptions);
        }
        catch(e){
            console.error(e)
        }

    }

}

the html that displays the data on the screen

 <ion-list>
                        <ion-item>
                            Accurary: {{geoposition.coords.accuracy}}
                        </ion-item>
                        <ion-item>
                            Latitude: {{geoposition.coords.latitude}}
                        </ion-item>
                        <ion-item>
                            Longitude: {{geoposition.coords.longitude}}
                        </ion-item>
                        <ion-item>
                            Timestamp:{{geoposition.timestamp |date}}
                        </ion-item>

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.