无法解析Push的所有参数:(?,?)

时间:2017-05-23 08:22:47

标签: android push-notification ionic2

我是Ionic2的新人。我正在开发离子2的测试应用程序,它有很多功能(短信,电话号码,图表,MySql,推...)我只是按照推动的步骤通知。push notification link。但是我得到了一个错误,我没有得到原因。我在哪里犯错误

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': 'xxxxxxx',
 },
    'push': {
      'sender_id': 'xxxxxxxxx',
     '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 {}

1 个答案:

答案 0 :(得分:5)

您需要让云客户端设置为Push。查看here

CloudModule添加到导入。

imports: [
    BrowserModule,
    HttpModule,
    CloudModule.forRoot(cloudSettings), //here
    IonicModule.forRoot(MyApp)
   ],