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 ?
Steps to reproduce:
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 :)
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.
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"
],