問題描述
我使用這個(gè)插件來獲得本地通知:https://github.com/katzer/cordova-plugin-local-notifications/wiki/03.-安裝
I use this plugin to have local notification : https://github.com/katzer/cordova-plugin-local-notifications/wiki/03.-Installation
我想在我的通知中有一個(gè)特定的圖標(biāo).它位于我的/www/assets/images/文件夾中.
I want to have a specific icon in my notification. It is located in my /www/assets/images/ folder.
我嘗試過這種方式,但它不起作用,我有一個(gè)帶鈴鐺的方形圖標(biāo):
I try this way but it doesn't work, I have a square icon with a bell :
public schedule() {
cordova.plugins.notification.local.schedule({
title: "New Message",
message: "Hi, are you ready? We are waiting.",
sound: null,
at: new Date(new Date().getTime() + 5 * 1000),
icon: 'file://assets/images/logo2.png'
});
}
有人可以告訴我我必須寫的路徑類型嗎?我迷路了.
Someone can show me the type of path I have to write ? I'm lost.
推薦答案
我找到了解決方案:
我在/platforms/android/res/中創(chuàng)建了一個(gè)名為drawable"的新文件夾我將我的圖片放在名為ic_notifications.png"和ic_notifications_small.png"的新文件夾中.
I create a new folder named "drawable" in /platforms/android/res/ I put my image in my new folder with name "ic_notifications.png" and "ic_notifications_small.png".
在我寫的代碼中
cordova.plugins.notification.local.schedule({
id: 2,
title: "Notification",
message: "Retour à l'application",
sound: null,
at: new Date(new Date().getTime() + 5 * 1000),
icon: 'ic_notifications',
smallIcon: 'ic_notification_small'
});
而且它有效!
這篇關(guān)于Ionic 2:本地通知圖標(biāo)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!