【问题标题】:ionic 2 local notification not showingionic 2本地通知未显示
【发布时间】:2018-06-11 06:47:25
【问题描述】:

我是第一次使用 ionic 2 本地通知。我关注了这个YouTube tutorial

当我在 Xcode 中测试我的应用时,我在下方收到一条警告消息,并且通知消息没有显示...不知道为什么。

警告:未知属性:在

我已经安装了

ionic cordova 插件添加 de.appplant.cordova.plugin.local-notification

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】:

    参考通知演示: https://github.com/husainsr/Ionic3_Notification 愿它对您有所帮助。

    【讨论】:

    • 按照说明在 android 设备和 xcode 模拟器上安装了应用程序,日期选择器或设备键盘未显示。因此无法测试通知。
    • 能否请您检查一下,如果有任何错误,请给我更多信息?
    • ERROR 错误:未捕获(承诺):cordova_not_available
    • 由于错误中提到cordova不可用,请尝试安装cordova并重试。
    • drive.google.com/open?id=1OzrMjCjpnkJXpl-dSOZ7fgs4V_JTGGn9 在这里我已经修改了 src 文件,只需下载删除现有的 src 文件并粘贴即可。希望它有效。
    猜你喜欢
    • 2017-06-26
    • 2017-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-31
    相关资源
    最近更新 更多