Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 离子2云推送不工作-应用程序崩溃_Ionic Framework_Ionic2 - Fatal编程技术网

Ionic framework 离子2云推送不工作-应用程序崩溃

Ionic framework 离子2云推送不工作-应用程序崩溃,ionic-framework,ionic2,Ionic Framework,Ionic2,我已经创建了IONIC 2应用程序,在最后阶段我正在尝试实现IONIC云推送,但它不起作用,每次我启用云推送注册功能时,应用程序都会崩溃: this.push.register().then((t: PushToken) => { return this.push.saveToken(t); }).then((t: PushToken) => { console.log('Token saved:', t

我已经创建了IONIC 2应用程序,在最后阶段我正在尝试实现IONIC云推送,但它不起作用,每次我启用云推送注册功能时,应用程序都会崩溃:

            this.push.register().then((t: PushToken) => {
          return this.push.saveToken(t);
        }).then((t: PushToken) => {
          console.log('Token saved:', t.token);
        });
我正在我的真实设备中使用“爱奥尼亚运行android”运行构建

请帮帮我,我做错了什么。我到处查看了许多文章,其中说明了我已经实施的相同流程:-

npm install @ionic/cloud-angular --save
cordova plugin add phonegap-plugin-push --variable SENDER_ID=12341234 --save
ionic io init
以及所有其他配置

下面是我的app.component.ts

    import { Component, ViewChild } from '@angular/core';
import { Nav, Platform, ToastController } from 'ionic-angular';
import { Events } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { Storage } from '@ionic/storage';
import { TabsComponent } from '../pages/tabs/tabs-component/tabs.component';
import { LoginComponent } from '../pages/login/login-component/login.component';

import { Push, PushToken } from '@ionic/cloud-angular';
//import { Push } from 'ionic-native';
//import { CloudSettings, CloudModule } from '@ionic/cloud-angular';
//import { Push, PushObject, PushOptions } from "@ionic-native";


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

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

    rootPage = TabsComponent;
    user: any;

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

    constructor(
        public push: Push,
        public platform: Platform,
        private storage: Storage,
        private toastController: ToastController,
        public events: Events
        ) {

        this.initializeApp();

        events.subscribe('userloggedin', user => {  
          if(user){
            this.user = user;
          }
        });

        storage.get('wordpress.user').then((value) => {
            if (value) {
                this.user = value;
            } 
        });

        this.pages = [
          { title: '????? ????', component: TabsComponent, category: { class:'home' }},
          { title: '?????????', component: LoginComponent, category: {class: 'category'}}
        ];

    }

    initializeApp() {
        this.platform.ready().then(() => {
            // Enable RTL Support
            // this.platform.setDir('rtl', true);
            StatusBar.styleDefault();
            Splashscreen.hide();


// ############## P U S H ###############
            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);
            // });
// ############## P U S H ###############


        });
    }


    openPage(page, index) {

        //check if page or post has been called
            this.nav.setRoot(page.component);
        }
    }

    login(){
        this.nav.push(LoginComponent);      
    }

    logout() {
        this.user = undefined;
        this.storage.remove('wordpress.user');
        this.nav.setRoot(LoginComponent);
    }

    profile() {     
        this.nav.push(ProfilePage);
    }
}
请帮忙


谢谢

它在真正的设备上对我来说工作得非常好

应用程序组件.ts

应用程序模块.ts


在真正的设备上,它对我来说工作得非常好

应用程序组件.ts

应用程序模块.ts


最后,我发现过时的cordova splash插件导致了这个错误,重新安装没有升级,因为在config.xml中有旧版本的插件

我刚刚删除了插件,并从config.xml中删除了行,然后重新安装,它成功了


以防万一,它可能也适用于其他人

最后我发现过时的cordova splash插件导致了这个错误,重新安装没有升级,因为在config.xml中有旧版本的插件

我刚刚删除了插件,并从config.xml中删除了行,然后重新安装,它成功了


以防万一,它可能也适用于其他人

你能分享插件的url吗?我想这是一个-但我遵循了爱奥尼亚文档什么是正确的方式@你能分享这个插件的url吗?我想是这个-但我遵循了爱奥尼亚文档的正确方法是什么@苏拉吉
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { SharedModule } from './shared/shared.module'
import { TabsModule } from '../pages/tabs/tabs.module';
import { SignUpModule } from '../pages/signup/signup.module'; //SSSS
import { ProfileModule } from '../pages/profile/profile.module'; //SSSS
import { MyApp} from './app.component';


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

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

@NgModule({
  declarations: [
    MyApp
  ],
  imports: [
    IonicModule.forRoot(MyApp, {
      backButtonIcon: 'arrow-back'
    }),
    CloudModule.forRoot(cloudSettings),
    SharedModule,
    TabsModule,
    SignUpModule,
    ProfileModule,
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp
  ],
  providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { Push, PushToken } from '@ionic/cloud-angular';

import { HomePage } from '../pages/home/home';
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage: any = HomePage;

  constructor(platform: Platform, public push: Push) {
    platform.ready().then(() => {

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


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

const cloudSettings: CloudSettings = {
  'core': {
    'app_id': '525f53a4'
  },
  'push': {
    'sender_id': '837506444622',
    'pluginConfig': {
      'ios': {
        'badge': true,
        'sound': true
      },
      'android': {
        'iconColor': '#343434'
      }
    }
  }
};

@NgModule({
  declarations: [
    ],
  imports: [
    CloudModule.forRoot(cloudSettings)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    ],
  providers: [
    ]
})
export class AppModule { }