Created
March 30, 2017 23:28
-
-
Save jamlfy/71e5efcfc8752dd185d926909f95bc97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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