1

I've used Notifications working on a JavaScript app and It's very useful when you don't have to be all the time looking at the app when something important needs to be acknowledged. I tried to replicate some work on Dart but a reference error is shown on compiled to JS Chrome.

Do you know if It's going to be implemented for Chrome soon? or is It going to remain experimental?

Thanks in advance

This is the function which tries to call Notification API. Without Notification line, everything works, when I add Notification line I get this error "Uncaught ReferenceError: requestPermission is not defined" running the code as JavaScript. (I am importing 'dart:html')

void revisarInput() {

    if ( valorLogin != '' ) {
        indicador = true;
        _ws.send( Util.formatearJsonSocket( 'loginPwd', { 'pwd': int.parse( valorLogin )}));
    }

    Notification.requestPermission();
}
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
hectorfh
  • 43
  • 4

2 Answers2

1

This was a bug in dart2js, https://code.google.com/p/dart/issues/detail?id=22483 and is fixed for Dart 1.9.

Alan Knight
  • 2,759
  • 1
  • 15
  • 13
0

This page says

https://developer.chrome.com/apps/notifications

Stable since Chrome 28

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • I know, that's why I think It's weird Dart don't compiled It to JavaScript – hectorfh May 20 '14 at 15:40
  • The answer to this question http://stackoverflow.com/questions/5040107/ says you can call this method only in an event handler of a user gesture like onClick. See also: https://code.google.com/p/chromium/issues/detail?id=274284 (fixed 5 days ago) Firefox allows it on the onLoad event but Chrome doesn't https://developer.mozilla.org/en-US/docs/WebAPI/Using_Web_Notifications (this link points also to the issue above) – Günter Zöchbauer May 20 '14 at 15:50
  • The method I used is called after on a change event over an input element. This is the listener registration on my polymer element: on-change="{{ revisarInput }}". I have this same component written on JavaScript, I'm doing the port to Dart. – hectorfh May 20 '14 at 16:25
  • Can you try a the onClick event of a button just to be sure? – Günter Zöchbauer May 20 '14 at 16:28
  • Tried with an onClick event on a button but I still got the error "requestPermission is not defined" when running as JavaScript – hectorfh May 20 '14 at 16:38
  • Then I would file a bug at dartbug.com – Günter Zöchbauer May 20 '14 at 16:40
  • I tried on Firefox stable too with same result as with chrome :( – hectorfh May 20 '14 at 16:54
  • I would file a bug. Please add a link to this question and add a link here to the new issue. – Günter Zöchbauer May 20 '14 at 16:56
  • 1
    Opened https://code.google.com/p/dart/issues/detail?id=18920. Thanks for your comments – hectorfh May 20 '14 at 19:30