[PWA Local Notifications] Postpone minutes and seconds at sample not working

Forge Component
(0)
Published on 11 Mar by Ruben Goncalves
0 votes
Published on 11 Mar by Ruben Goncalves

Hi,

when tryng to send notifications with postpone the sample does not work. In fact, a notification is immediately shown.

Using google chrome Version 83.0.4103.61.

Thank you,

Luis

Hi,

I am very sorry, but after reading the code of this component I realized that the functionality send notification with postpone it is not a "schedule notification". Therefore it works, that is, a timestamp is shown in the local notification with the postpone time defined by me. 

After implementin the code for the "Schedule Notification", I got the message from outsystems that the Notification Trigger API is not supported:

Is there any plans from outsystems to support this feature?

Thank you and best regards,

Luis

Hi Luis,

That appears to be a message from the browsers, not from the platform anyhow.

Can you provide some more details, or a sample page, to see how you're using it?

Thanks,

Cheers,

RG


Luis Barqueira wrote:

Hi,

I am very sorry, but after reading the code of this component I realized that the functionality send notification with postpone it is not a "schedule notification". Therefore it works, that is, a timestamp is shown in the local notification with the postpone time defined by me. 

After implementin the code for the "Schedule Notification", I got the message from outsystems that the Notification Trigger API is not supported:

Is there any plans from outsystems to support this feature?

Thank you and best regards,

Luis



Hi Ruben,

I created a PWA app with outsystems, and I am using the sample provided at 

https://whatwebcando.today/scheduler.html

The code is presented next In OS I have used a Button that onclick call a JS node with the fuction schedulenotification(). For the JS code is included in Script as a file that is referenciated at the screen where the function is called.

HTML:

<p><button onclick="scheduleNotification()">Schedule notification in 10s<br>(using Notification Trigger API)</button></p>

JS:

function scheduleNotification() {
  if (!('Notification' in window)) {
    alert('Notification API not supported');
    return;
  }
  if (!('showTrigger' in Notification.prototype)) {
    alert('Notification Trigger API not supported');
    return;
  }
  
  Notification.requestPermission()
    .then(() => {
      if (Notification.permission !== 'granted') {
        throw 'Notification permission is not granted';
      }
    })
    .then(() => navigator.serviceWorker.getRegistration())
    .then((reg) => {
      reg.showNotification("Hi there from the past!", {
          showTrigger: new TimestampTrigger(new Date().getTime() + 10 * 1000)
      })
    })
    .catch((err) => {
      alert('Notification Trigger API error: ' + err);
    });

When I run the app the message I get is the one I presented in the last post, i.e., "Notification Trigger API not supported".

Thank you and best regards,

Luis


Hi Ruben,

meanwhile, I explored deeply, and in order to use Notification Trigger API, we have to enable #enable-experimental-web-platform-features at chrome://flags. When I did it,  the scheduled notification presented in my last post has worked fine.

I have to congratulate Outsystems to the release of PWA. I have some questions about Outsystems PWA but this is not the forum for that.

Thank you and best regards,

Luis


Hi Luis,

Good to hear.

Just some notes for future reference:

  • This component, already encapsulates what you're trying to do, in a low-code fashion.
  • This component, is unsupported and completely unrelated with OutSystems as a company.
  • When you have this kind of error, it's browser related not OutSystems.
  • Finally, questions that are not related with the component, show be done in the appropriate forum ??, otherwise you risk not getting enough attention to your question.

If you have any question, regarding the component and it's usage, please let me know.

Best regards,

RG