如何使用离子2在通知中显示自定义图像

时间:2016-09-20 12:40:56

标签: angular cordova-plugins ionic2

问题是通知中出现方形空白图像。

我已安装本地通知插件

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

我试过

1) 保存在platforms\android\res\drawable\sample.png

中的图片

这是代码

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {LocalNotifications} from 'ionic-native';
@Component({
  templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController) {
    LocalNotifications.schedule({
      id: 1,
      title: 'Title here',
      text: 'Text <b>here aaa</b>',
      led: "FF0000",
      icon: "sample"
    });
  }
}

2) 保存在\www\img\sample.png

中的图片

这是代码

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {LocalNotifications} from 'ionic-native';
@Component({
  templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController) {
    LocalNotifications.schedule({
      id: 1,
      title: 'Delay Notification',
      at: new Date(new Date().getTime() + 3600),
      text: 'Text <b>here aaa</b>',
      led: "FF0000",
      icon: "file://android_asset/www/img/sample.png"
    });
  }
}

0 个答案:

没有答案
相关问题