Monday, May 6, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 13244  / 1 Year ago, sat, march 25, 2023, 1:39:09

I'm trying to get native notifications to work using Google Chrome (or Chromium) on Ubuntu, but no luck so far.



Things I've tried already:





And I remember I've tried another extension as well but I don't remember its name.



None of them work. I keep getting the normal notifications of Chrome itself.



I'm using Google Chrome 34.0.1847.137 on Ubuntu 14.04 x64.



Can someone tell me how to get this working?


More From » google-chrome

 Answers
6

For LibNotify, the JSON file that it installs has the incorrect extension ID. Updating the extension ID to the correct one fixes it.



Go to .config/google-chrome/NativeMessagingHosts (for Google Chrome) or .config/chromium/NativeMessagingHosts (for Chromium). Open up the JSON file in the folder, and notice that in the allowed_origins section, it allows the extension ID gphchdpdmccpjmpiilaabhpdfogeiphf. However, the extension ID (at least in my case, but it should be the same for everyone) is actually epckjefillidgmfmclhcbaembhpdeijg.



To fix this, either replace the incorrect extension ID with the correct one, or add a comma and the correct extension ID after it. I personally chose the latter option, and here's what my JSON file looks like:



{
"name": "com.initiated.chrome_libnotify_notifications",
"description": "Libnotify Notifications in Chrome",
"path": path to the location of install.sh,
"type": "stdio",
"allowed_origins": [
"chrome-extension://gphchdpdmccpjmpiilaabhpdfogeiphf/",
"chrome-extension://epckjefillidgmfmclhcbaembhpdeijg/"
]
}


EDIT: That's not the only change that needs to be made. The extension relies on Webkit notifications, which were deprecated and removed in Chrome(ium) and likely other browsers in favor of HTML5 notifications. Therefore, google-chrome/default/Extensions/epckjefillidgmfmclhcbaembhpdeijg/1.0_0/notify_hook.js needs to be updated. I've written a short script for this, but it breaks most of the standard except for displaying the notification. Replace everything in the file with the following (added basic support for sites still using window.webkitNotifications and (hopefully) improved image support) (permissions support added):



OriginalNotification = Notification

Notification = function(title, properties) {
if (Notification.permission != "granted") {
if (this.onError) {
this.onError();
}
return;
}
if (!properties.hasOwnProperty("body")) {
properties["body"] = "";
}
if (!properties.hasOwnProperty("icon")) {
properties["icon"] = "";
}
if (properties["icon"]) {
properties["icon"] = getBaseURL() + properties["icon"];
}
document.getElementById('libnotify-notifications-transfer-dom-area').innerText = JSON.stringify({title:title, body:properties["body"], iconUrl:properties["icon"]});
var event = document.createEvent("UIEvents");
event.initUIEvent("change", true, true);
document.getElementById('libnotify-notifications-transfer-dom-area').dispatchEvent(event);
if (this.onShow) {
this.onShow();
}
};

Object.defineProperty(Notification, "permission", {
get: function() {
return OriginalNotification.permission;
},
set: undefined
});

Notification.requestPermission = function(callback) {
OriginalNotification.requestPermission(callback);
}

window.webkitNotifications = {}

window.webkitNotifications.checkPermission = function() {
return 0;
}

window.webkitNotifications.createNotification = function(image, title, body) {
if (image) {
image = getBaseURL() + image;
}
document.getElementById('libnotify-notifications-transfer-dom-area').innerText = JSON.stringify({title:title, body:body, iconUrl:image});
var event = document.createEvent("UIEvents");
event.initUIEvent("change", true, true);
document.getElementById('libnotify-notifications-transfer-dom-area').dispatchEvent(event);
}

function getBaseURL() {
return location.protocol + "//" + location.hostname +
(location.port && ":" + location.port) + "/";
}

[#25232] Saturday, March 25, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
termetalli

Total Points: 326
Total Questions: 127
Total Answers: 110

Location: Sao Tome and Principe
Member since Sat, Sep 12, 2020
4 Years ago
termetalli questions
Sat, Apr 30, 22, 17:54, 2 Years ago
Mon, Dec 6, 21, 05:24, 2 Years ago
Thu, Jun 30, 22, 00:32, 2 Years ago
Mon, Dec 19, 22, 00:15, 1 Year ago
;