离子2本地通知未显示

问题描述 投票:1回答:1

我第一次使用离子2本地通知。我跟着这个YouTube tutorial

当我在Xcode中测试我的应用程序时,我收到下面的警告消息并且通知消息没有显示...不确定原因。

警告:未知财产:at

我安装了

离子cordova插件添加de.appplant.cordova.plugin.local-通知

npm install --save @ ionic-native / local-notifications

并在src / app / app.module.ts中添加了插件作为提供程序

我有以下代码:

home.html的:

<button ion-button (click)=myNotifications()>Test</button>

app.module.ts

import { Component } from '@angular/core';
import { NavController, Platform, ActionSheetController, AlertController } from 'ionic-angular';
import { ScreenOrientation } from '@ionic-native/screen-orientation';
import { LocalNotifications } from '@ionic-native/local-notifications';


    export class HomePage {

      constructor(public navCtrl: NavController,
                  public platform: Platform,
                  private screenOrientation: ScreenOrientation,
                  private localNotifications: LocalNotifications,
                  public alertCtrl: AlertController ) {

                    this.platform.ready().then((ready) =>{
                      this.localNotifications.on('click', (notification, state) => {
                        let json = JSON.parse(notification.data);

                        let alert = this.alertCtrl.create({
                          title: notification.title,
                          message: json.fullMsq
                        });
                        alert.present();
                      });
                    });
      }

      myNotifications() {

        this.localNotifications.schedule({
          id: 1,
          title: 'ABC Meeting Notification',
          text: 'ABC Meeting will start in 20 mins',
          at: new Date(new Date().getTime() + 20*60*1000),
          data: { fullMsq: 'this is the full notification message' }
        })
      }

    }
cordova ionic-framework ionic2
1个回答
1
投票

参考通知演示:https://github.com/husainsr/Ionic3_Notification可能证明对您有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.