离子2本地通知未显示 [英] ionic 2 local notification not showing

查看:116
本文介绍了离子2本地通知未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用ionic 2本地通知。我已经按照 YouTube教程进行了操作。

I'm working with ionic 2 local notification for the first time. I've followed this YouTube tutorial.

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

When I test my app in Xcode, I'm getting a warning message below and the notification message doesn't show... not sure why.


警告:未知财产:at

WARN: Unknown property: at

我已安装


ionic cordova plugin add de.appplant.cordova.plugin.local-notification

ionic cordova plugin add de.appplant.cordova.plugin.local-notification

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

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

    }


推荐答案

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

Refer Notification Demo: https://github.com/husainsr/Ionic3_Notification May it Proves Helpful to you.

这篇关于离子2本地通知未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆