'Alarm API on internally developed chrome extension not working properly after migration to Manifest v3

Two years ago, we developed a custom Chrome Extension using manifest v2 which triggers popups either at regular intervals (every 45 mins or 20 mins after being snoozed) or scheduled notifications (daily or weekly).

The Extension allows configurable time intervals by using the chrome.alarms API to schedule code to "run periodically or at a specified time in the future".

After upgrading the extension to use manifest v3, following the instructions in the Manifest v3 migration checklist, we ran multiple tests which failed. We think it's because the chrome.alarms API won't trigger or get triggered if the extension is idle for a day or more.

The problem started after migrating to manifest v3. The chrome.alarms API doesn't fire daily nor at the interval set, and it doesn't show any notifications.

Any ideas on how can we achieve this with manifest v3 as we did with manifest v2? What should we be looking at? Has anyone else seen this issue?

function triggerAlarm() {
    chrome.storage.local.get(['delayInMinutes'],function(res){
        console.log(res);
//code for creating alarm
chrome.alarms.create('createAlarm', {
            delayInMinutes:delayInMinutes
        });
    });
//code to listen the alarm
chrome.alarms.onAlarm.addListener(alarmListener);
    chrome.alarms.get('createAlarm', function (alarm) { });
}
function alarmListener(alarm) {
//business logic
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source