I'm developing a mobile application using the Ionic framework and am currently trying to configure local notifications. I'm using ngCordova with the local-notification plugin.
The notifications are currently working, but I can't seem to figure out how to set the icon from a local file. My image is currently located in my ionic project repository at path 'www/img/image.png'. I'm trying to schedule the notification using the following code:
var alarmTime = new Date();
alarmTime.setMinutes(alarmTime.getMinutes() + 15);
$cordovaLocalNotification.schedule({
id: Math.random().toString(),
date: alarmTime,
message: 'Timeout Warning',
title: 'Return to prevent your session from expiring.',
autoCancel: false,
icon: 'img/image.png'
}, $scope);
The notification works, but the desired icon does not appear. In the icon option, I've also tried 'www/img/image.png', as well as 'file://img/image.png'. Each time, I always see the default cordova robot icon instead of the icon I'm trying to specify.
Does anyone have any tips on how to set the icon option properly? The documentation gives examples using external images, but is it possible to use a local image?
The icon name in the above example points to the location:
/platforms/android/res/drawable/
To make the plugin use the icons, the image files must be located in this path and named as defined in the parameters. In this case they are:Found the solution here: ngCordova + local notification plugin
Also, check the plugin documentation on github: https://github.com/katzer/cordova-plugin-local-notifications
It seems that you should use an icon from public url, try uploading your icon to a public reachable url (drive, drobpox, tinypng .. ).