question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android notification always appear to show the default ic_popup_reminder (bell-like) icon regardless

See original GitHub issue

I have setup the local notifications and they work really well with the Ionic framework. Within my Ionic Ready block I have the following code in which I have set the icon image (I am using this image http://sciactive.com/pnotify/includes/github-icon.png)

As the path is relative to the app.js file, the image is up a level within a folder called ‘img’ and the file is called ‘github-icon.png’.

For some reason the same ‘bell’ default icon always appears?? Is this a bug? I am using Android 6.0.1 on my Nexus 5.

$scope.scheduleSingleNotification = function () {
      $cordovaLocalNotification.schedule({
        id: 1,
        title: 'Warning',
        text: 'my first notification!',
        icon: 'file://img/logo.png',
      }).then(function (result) {
        console.log('Notification #1 triggered');
      });
    };

https://github.com/katzer/cordova-plugin-local-notifications/wiki/10.-URIs This is the image that appears in my local notification ftp://ftp.gunadarma.ac.id/android/sdk/sdk_310712/docs/resources/samples/ApiDemos/res/drawable-hdpi/ic_popup_reminder.html

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
pgcdcommented, Mar 18, 2017

It took me a loooooong time but I think I have it completely under control! My relevant notification options are: { icon: 'file://assets/icon/notification_icon.png', smallIcon: 'res://ic_notification_icon_large' } The first is a 128x128 icon in /src/assets/icon/notification_icon.png (it’s the one you see when you pull down the notification area) - I have tried several other sizes and this seemed the correct one. The second (the res:// one) is actually a set of icons that I prepared with http://romannurik.github.io/AndroidAssetStudio/ using asset size = 24dp. The result is a handy zip containing a single “res” folder - just copy this folder in your /platforms/android folder so that it merges with the existing “res” folder there, and voilà, all the properly resized icons are there.

2reactions
mix3dcommented, Mar 29, 2016

@gilvandev, where is your file located, in the /platforms/android/ project? Are you familiar with the structure of Android projects? When you specify with res://, that means the url needs to point to a file in the platforms/android/res/ folder, but also split into the various DPI resolutions folders (drawable-xhdpi, drawable-hdpi, etc). Furthermore, because of the way android has setup it’s ‘drawable’ resources, you don’t add the filetype extension.

Example: you set the icon to “res://alerticon”, and android will determine the screen density of the device running your app (lets say it is xhdpi), then it looks in the res/drawable-xhdpi/ folder for any file named “alerticon”, and finds your icon as alerticon.png. If it doesn’t find it in the “correct” density folder, it will look in all the other density folders for the closest match, finally looking in res/drawable/.

I have a script hook to copy my icon into the correct folders, that runs on the after_platform_add cordova hook, to copy them from my www folder into the correct res folder.

TLDR: res:// won’t find files in the www folder

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my app always show the default icon on a push ...
I icons listed on the left show up just fine in Android Studio if you double click each of them. (I feel there's...
Read more >
Android: Notification Icons - OneSignal Documentation
The small icon is displayed on the top status bar as well as the notification itself. By default OneSignal will show a bell...
Read more >
Control notifications on Android - Google Support
Open your phone's Settings app. · Tap Notifications and then Notifications on lock screen. Choose your phone's notification defaults: Show conversation, default, ...
Read more >
Notifications Overview | Android Developers
A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found