Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 2 : Local notification icon

I use this plugin to have local notification : https://github.com/katzer/cordova-plugin-local-notifications/wiki/03.-Installation

I want to have a specific icon in my notification. It is located in my /www/assets/images/ folder.

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.

like image 395
V. Pivet Avatar asked Feb 08 '17 15:02

V. Pivet


People also ask

How to set icon in local notification in ionic?

For Local push notification of ionic 2 plugin you can set the icon like below. Here icon. png will be taking from the drawable folder in android. And you can configure ionic to copy the local image file to drawable folder by adding lines mentioned below in config file under android platform section.

What is a local notification?

Local notifications are scheduled by an app and delivered on the same device. They are suited for apps with time-based behaviors, such as calendar events. When you run your app on a device with Android OS 8.0 or above, Kony uses default channels that are mentioned in the localnotificationconfig.


1 Answers

For Local push notification of ionic 2 plugin you can set the icon like below. Here icon.png will be taking from the drawable folder in android. And you can configure ionic to copy the local image file to drawable folder by adding lines mentioned below in config file under android platform section.

<platform name="android">
<resource-file src="resources/android/icon/icon.png" target="res/drawable/icon.png"/>
</platform>
        

this.localNotifications.schedule({
          id: 1,
          title: data.title,
          text: data.body,
          data: data,
          icon: "res://icon.png",
          smallIcon:"res://icon.png"
        });
like image 182
Sathyajith Avatar answered Oct 06 '22 00:10

Sathyajith