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.

Notification sound and icon on Android

See original GitHub issue

Hi, there!

I’m having issues with the sound of the notifications, at first I think it vibrated (may be wrong about this), now it does nothing. Here’s my code:

var date = '2016-08-11';
var time = '04:16';
var title = 'Test';
var message = 'This is a test';

var schedule_time = new Date((date + " " + time).replace(/-/g, "/")).getTime();
schedule_time = new Date(schedule_time);

window.plugin.notification.local.schedule({
    id:         "1", 
    date:       schedule_time,
    message:    message,
    title:      title,
    sound:      'SYSTEM_DEFAULT',
    icon: 'www/icon.png' //It's a 300x300 icon
    autoCancel: true
});

I’ve tried putting ‘android.resource://’ + package_name + ‘/raw/beep’ (beep is stored in www/ and in platforms/android/res/raw), ‘android.resource://’ + package_name + ‘/raw/beep.mp3’ (just added the .mp3), ‘TYPE_ALARM’, ‘SYSTEM_DEFAULT’, ‘www/beep.mp3’, ‘file:///www/beep.mp3’, an URL… To no avail, no sound at all. I’ve tried with the icon too, but less stuff, just the URL and the file path there’s in the code I wrote here, just appears a square with rounded corners instead of the bell.

The version I’m using is the 0.8.4, and the Android version is 6.0.1.

Thanks in advance for your help!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
grumpygarycommented, Mar 15, 2017

create a folder in cordova “platforms/android/res/drawable” copy your icon into it (name must be lower case – make it “sm_icon.png”) refer to is as “res://sm_icon.png” in notification

2reactions
RangerMauvecommented, Aug 22, 2016

For the icon you should prefix it with file so it looks like so: file://icon.png. You can omit the www part because the file:// protocol automatically adds this. This is documented here on the wiki

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get Sound Notifications on your phone - Google Help
Open your device's Settings app . · Tap Accessibility and then Sound Notifications. · Tap Open Sound Notifications and then Settings . ·...
Read more >
4 Ways to Add Notification Sounds on Android - wikiHow
1. Save a custom sound to your Android. There's a variety of ways to find and save custom sounds. You can download them...
Read more >
How to Change Android Notification Sounds - Lifewire
Go to Settings > Apps & notifications > Notifications. · Scroll down and tap Advanced > Default notification sound. · Tap My Sounds....
Read more >
How to Change the Notification Sound on an Android
1. Open the Settings app on your Android device. 2. Tap "Sound." 3. Tap "Default notification sound." Depending on the ...
Read more >
Notification Sounds - Apps on Google Play
Notification Sounds is a collection of free ringtones and wallpapers that contains some of the best notification tones, message sounds and great wallpapers ......
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