Sampath Sampath - 6 months ago 52
TypeScript Question

Ionic deploy with Injecting Deploy

I have never used Ionic Deploy service.I would like to use it now.I have a question here.Hope you'll help me.

According to the above doc, I have to do this:

Import Deploy from the Cloud Client and specify it as a dependency in
your component constructor.

import {Component} from '@angular/core';
import {Deploy} from '@ionic/cloud-angular';

@Component( ... )
export class MyPage {
constructor(public deploy: Deploy) {

Do I need to this for each and every
or where? According to the official doc, it seems
.Can't I use in a single place like
? Why do we need to replicate it on each and every

Answer Source

In my app I did it on app startup so in app.component.ts i did injection and then on platform ready checked if there is new update.

    import { Component } from '@angular/core';
import { Platform, LoadingController } from 'ionic-angular';
import { Deploy } from '@ionic/cloud-angular';

  templateUrl: 'app.html'
export class MyApp {
  rootPage = TabsPage;
  constructor(private platform: Platform,
    public deploy: Deploy) {
    platform.ready().then(() => {


  checkUpdate() {
      .then((snapshotAvailable: boolean) => {
        if (snapshotAvailable) {
 => {
            return this.deploy.extract()
              .then(() => {

You can also do it in page if you wish for instance you can add about app page and each time user hit this page you check for new version

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download