Ionic-framework: Push notification error : ORIGINAL EXCEPTION: No provider for Push!

Created on 11 Oct 2016  路  8Comments  路  Source: ionic-team/ionic-framework

Hi,
I am having an issue implementing push notification on my app : I got the following error while serving : ORIGINAL EXCEPTION: No provider for Push!

Looking for answers I found former topics mentioning conflict using @viewchild and passing provider in constructor. https://github.com/driftyco/ionic/issues/5543 But I can't figured this out...

Any idea ?

What behavior are you expecting?

Steps to reproduce:

  1. start a sidemenu app
  2. follow the push notification guide https://docs.ionic.io/services/push/
  3. serve

My app.component :

import { Push, PushToken } from '@ionic/cloud-angular';

@Component({
  templateUrl: 'app.html'
})

export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage: any = HomePage;

  pages: Array<{title: string, component: any, icon: string}>;

/* PASS PUSH IN CONSTRUCTOR */
  constructor(public platform: Platform, public wp: ApiWp, public push: Push) {
    this.initializeApp();

    // used for an example of ngFor and navigation
    this.pages = [
      { title: 'Actualite', component: ActualitesPage, icon:'text' },  
      { title: 'R茅glages', component: SettingsPage, icon:'settings' }    
    ];

  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();


          /*BEGINNING  OF PUSH NOTIFICATION CODE */

    this.push.register().then((t: PushToken) => {
        return this.push.saveToken(t);
      }).then((t: PushToken) => {
        console.log('Token saved:', t.token);
      });

      this.push.rx.notification()
  .subscribe((msg) => {
    alert(msg.title + ': ' + msg.text);
  });
  /* END */
    });

  }

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Which Ionic Version? 1.x or 2.x
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: 1.8.7
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v5.12.0
Xcode version: Xcode 8.0 Build version 8A218a

Thanks :)

Most helpful comment

Hi
Please add CloudModule in app.module.ts

import { CloudSettings, CloudModule } from '@ionic/cloud-angular';

@NgModule({
declarations: [
MyApp,
HelloIonicPage,
ItemDetailsPage,
ListPage
],
imports: [
IonicModule.forRoot(MyApp),
CloudModule.forRoot(cloudSettings) // this module need to be add to resolve "No Provider Issue"
],

All 8 comments

solution? having same issue here

any solution

I could not make that work with @ionic/cloud-angular , the only way i could make was:

import { Push } from 'ionic-native';

export class App {

constructor(public app: App,platform: Platform){

  platform.ready().then(() => {
    let push = Push.init({
        android: {
          senderID: 'MYID'
        },
        ios: {
          alert: 'true',
          badge: true,
          sound: 'false'
        },
        windows: {}
      });
    }

     push.on('registration', (data) => {
          console.log("device token ->", data.registrationId);
        });
      push.on('notification', (data) => {
          console.log(data);

        })
  }

}

thanks i will try this

Hi
Please add CloudModule in app.module.ts

import { CloudSettings, CloudModule } from '@ionic/cloud-angular';

@NgModule({
declarations: [
MyApp,
HelloIonicPage,
ItemDetailsPage,
ListPage
],
imports: [
IonicModule.forRoot(MyApp),
CloudModule.forRoot(cloudSettings) // this module need to be add to resolve "No Provider Issue"
],

@dnyaneshwaruttarwar you've saved my life ! thx a lot !!!

I'm facing one issue, The notification is not getting a popup on my mobile device. Is anyone facing the same issue ?

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandyscarney picture brandyscarney  路  3Comments

brandyscarney picture brandyscarney  路  3Comments

Nick-The-Uncharted picture Nick-The-Uncharted  路  3Comments

MrBokeh picture MrBokeh  路  3Comments

manucorporat picture manucorporat  路  3Comments