mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 21:18:00 +01:00
Moved feature detect to seperate function
This commit is contained in:
parent
60f55e6223
commit
c649763409
2 changed files with 28 additions and 12 deletions
|
@ -107,17 +107,9 @@ module.exports = angular.module('ponyfm').factory('notifications', [
|
||||||
|
|
||||||
checkSubscription: () ->
|
checkSubscription: () ->
|
||||||
def = new $.Deferred()
|
def = new $.Deferred()
|
||||||
|
|
||||||
if 'serviceWorker' of navigator
|
if 'serviceWorker' of navigator
|
||||||
if !('showNotification' of ServiceWorkerRegistration.prototype)
|
if !self.checkPushSupport()
|
||||||
console.warn('Notifications aren\'t supported.')
|
|
||||||
def.resolve -1
|
|
||||||
|
|
||||||
if Notification.permission == 'denied'
|
|
||||||
console.warn('The user has blocked notifications.')
|
|
||||||
def.resolve -1
|
|
||||||
|
|
||||||
if !('PushManager' of window)
|
|
||||||
console.warn('Push messaging isn\'t supported.')
|
|
||||||
def.resolve -1
|
def.resolve -1
|
||||||
|
|
||||||
navigator.serviceWorker.ready.then (reg) ->
|
navigator.serviceWorker.ready.then (reg) ->
|
||||||
|
@ -135,5 +127,30 @@ module.exports = angular.module('ponyfm').factory('notifications', [
|
||||||
def.resolve -1
|
def.resolve -1
|
||||||
|
|
||||||
def.promise()
|
def.promise()
|
||||||
|
|
||||||
|
checkPushSupport: () ->
|
||||||
|
if !('showNotification' of ServiceWorkerRegistration.prototype)
|
||||||
|
console.warn('Notifications aren\'t supported.')
|
||||||
|
return false
|
||||||
|
|
||||||
|
if Notification.permission == 'denied'
|
||||||
|
console.warn('The user has blocked notifications.')
|
||||||
|
return false
|
||||||
|
|
||||||
|
if !('PushManager' of window)
|
||||||
|
console.warn('Push messaging isn\'t supported.')
|
||||||
|
return false
|
||||||
|
|
||||||
|
# If Chrome 50+
|
||||||
|
if !!window.chrome && !!window.chrome.webstore
|
||||||
|
if parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]) >= 50
|
||||||
|
return true
|
||||||
|
# If Firefox 46+
|
||||||
|
else if typeof InstallTrigger != 'undefined'
|
||||||
|
if parseInt(navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]) >= 46
|
||||||
|
return true
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
self
|
self
|
||||||
])
|
])
|
||||||
|
|
|
@ -3,4 +3,3 @@
|
||||||
expose_php = Off
|
expose_php = Off
|
||||||
post_max_size = 250M
|
post_max_size = 250M
|
||||||
upload_max_filesize = 200M
|
upload_max_filesize = 200M
|
||||||
extension=php_gmp.dll
|
|
Loading…
Reference in a new issue