Skip to content

JVasconsueloM/cordova-plugin-aspolar-signal-strength

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova plugin signal strength - ionic 2~3 ... min android API 17

Supported platforms

  • Android

Installation

  1. Install the Cordova plugin:

    cordova plugin add https://github.com/JVasconsueloM/aspolar-signal-strength.git

  2. Build the ionic wrapper Open terminal and write:

    ionic generate provider signal-strength

    Then copy and paste this on file created.

    import { Injectable } from '@angular/core';
    import { Cordova, Plugin, IonicNativePlugin } from "@ionic-native/core";
    
    /*
      Generated class for the SignalStengthProvider provider.
    
      See https://angular.io/guide/dependency-injection for more info on providers
      and Angular DI.
    */
    @Plugin({
      pluginName: 'SignalStrength',
      plugin: 'cordova-aspolar-plugin-signal-strength',
      pluginRef: 'window.plugins.signalStrength',
      repo: 'https://github.com/JVasconsueloM/aspolar-signal-strength',
      platforms: ['Android']
    })
    
    @Injectable()
    export class SignalStrengthProvider extends IonicNativePlugin  {
    
      @Cordova()
      getdBm(): Promise<any> {
        return; // We add return; here to avoid any IDE / Compiler errors
      }
    
      @Cordova()
      getPercentage(): Promise<any> {
        return; // We add return; here to avoid any IDE / Compiler errors
      }
    
      @Cordova()
      getLevel(): Promise<any> {
        return; // We add return; here to avoid any IDE / Compiler errors
      }
    }
  3. Add the plugin to Your App's Module

    ...
    
    import { SignalStrengthProvider } from "../providers/signal-strength/signal-strength";
    
    ...
    
    @NgModule({
      ...
    
      providers: [
        ...
        SignalStrengthProvider
        ...
      ]
      ...
    })
    export class AppModule { }
  4. for use...

    ...
    import { SignalStrengthProvider } from "../providers/signal-strength/signal-strength";
    ...
    
    export class HomePage{
      ...
      constructor(public navCtrl: NavController, private signalStrength: SignalStrengthProvider) {}
      ...
      getSignal() {
        this.signalStrength.getdBm().then((result) => {
          alert(result);
        }, (err) => {
          alert(JSON.stringify(err));
        });
      }
      ...
    }