Skip to content

Instantly share code, notes, and snippets.

@jamlfy
Created March 30, 2017 23:28
Show Gist options
  • Save jamlfy/71e5efcfc8752dd185d926909f95bc97 to your computer and use it in GitHub Desktop.
Save jamlfy/71e5efcfc8752dd185d926909f95bc97 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
@Injectable()
export class Notifications {
permition = false;
constructor() {
if (!("Notification" in window)) {
Notification.requestPermission( (e) => this.__granted(e));
}
}
__granted(e){
this.permission = e === "granted";
}
Notification (text:string) {
if(this.permission){
return {};
}
return new Notification(text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment