temperature-ionic
v1.0.3
Published
A Cordova plugin to get battery temperature
Downloads
10
Maintainers
Readme
cordova-plugin-temperature-geodata
Este plugin Cordova permite acessar a temperatura estimada da bateria e monitorar mudanças no estado térmico do dispositivo iOS.
Instalação
Para adicionar este plugin ao seu projeto Cordova, use o seguinte comando:
Uso
Uso no Ionic
Instalação do Plugin
Certifique-se de ter adicionado o plugin ao seu projeto Cordova usando o comando acima.
Configuração no TypeScript/JavaScript
No componente Ionic onde deseja acessar a temperatura da bateria, você pode implementar a seguinte lógica:
- Importe o plugin no seu componente.
- Use eventos do Cordova para garantir que o dispositivo esteja pronto antes de chamar a função do plugin.
- Chame a função para obter a temperatura da bateria e manipule o resultado conforme necessário.
Exemplo:
import { Component } from '@angular/core'; declare var TemperatureGeoData: any; @Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage { constructor() {} ionViewDidEnter() { document.addEventListener('deviceready', () => { this.getBatteryTemperature(); }); } getBatteryTemperature() { TemperatureGeoData.getBatteryTemperature( (temperature) => { console.log('Battery Temperature: ', temperature); // Use a temperatura conforme necessário }, (error) => { console.error('Erro ao obter temperatura da bateria: ', error); } ); } }