home.component.ts

import { Component } from '@angular/core';
import { BackandService } from '@backand/angular2-sdk';
import { NavController } from 'ionic-angular';
import { Market } from 'ionic-native';

@Component({
    selector: 'home-page',
    templateUrl: 'home.component.html'
})
export class HomeComponent {
    isUpdateAvailable:boolean = false;
    current_version:number = 1;

    constructor(public navCtrl: NavController, private backand: BackandService) {
        let version_id = "1";
        this.backand.object.getOne('version', version_id)
            .then((result: any) => {
                console.log('Data posted to DB');
                if(result !== undefined && result.data !== undefined) {
                    let latest_version:number = parseFloat(result.data.version);
                    if(this.current_version < latest_version) {
                        // Show update app button
                        this.isUpdateAvailable = true;
                    }
                }
            },
            (err: any) => {
                console.log(err);
            });
    }

    openMarket() {
        Market.open('in.jsbisht.creepychat');
    }
}