Onur Önder Onur Önder - 1 year ago 102
Android Question

Can't resolve all parameters for Push: (?, ?)

I'm new at Ionic2.I am developing a test application on ionic 2,There are many features in it(SMS,Call Number,Chart,MySql,Push ...)I just followed the steps for push notification.push notification link.But I get an error and I do not get the cause.Where do i make mistakes

app.component.ts

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {
Push,
PushToken
} from '@ionic/cloud-angular';

import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html',
providers: [Push]

})
export class MyApp {
rootPage:any = HomePage;

constructor(platform: Platform, statusBar: StatusBar, splashScreen:
SplashScreen,public push:Push) {
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();
splashScreen.hide();
});

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);
});

}
}


app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import {CallNumber} from '@ionic-native/call-number';
import { SMS } from '@ionic-native/sms';
import {ChartPage} from '../pages/chart/chart';
import {CallNumberPage} from '../pages/call-number/call-number';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
import { Toast } from '@ionic-native/toast';
import { HttpModule } from '@angular/http';
import {CloudSettings,CloudModule} from '@ionic/cloud-angular';


import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import {CanvasPage} from '../pages/canvas/canvas';
import {SqlitePage} from '../pages/sqlite/sqlite';
import {MysqlPage} from '../pages/mysql/mysql';
import {ServiceProvider} from '../providers/datamember';
import {ListPage} from '../pages/list/list';

const cloudSettings: CloudSettings = {
'core': {
'app_id': '9397ae48',
},
'push': {
'sender_id': '229628862274 ',
'pluginConfig': {
'ios': {
'badge': true,
'sound': true
},
'android': {
'iconColor': '#343434'
}
}
}
};


@NgModule({
declarations: [
MyApp,
HomePage,
ChartPage,
CallNumberPage,
CanvasPage,
SqlitePage,
MysqlPage,
ListPage
],
imports: [
BrowserModule,
HttpModule,

IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
ChartPage,
CallNumberPage,
CanvasPage,
SqlitePage,
MysqlPage,
ListPage
],
providers: [
StatusBar,
SplashScreen,
CallNumber,
SMS,
SQLite,
Toast,
ServiceProvider,
HttpModule,


{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}

Answer Source

You need to have the cloud client setup to use Push . Check here

Add CloudModule to imports.

imports: [
    BrowserModule,
    HttpModule,
    CloudModule.forRoot(cloudSettings), //here
    IonicModule.forRoot(MyApp)
   ],
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download