Skip to content

Commit

Permalink
Use alternative means to check if using browser vs cordova
Browse files Browse the repository at this point in the history
  • Loading branch information
ianngiaw committed Nov 12, 2015
1 parent d52c481 commit ccc42e0
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions www/js/services/chromeNotifService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ angular.module('letterbox.services')
.service('ChromeNotifService', function($timeout, eventbus, ChatService) {
var ChromeNotif = this;

if (!window.cordova) {
if (document.URL.indexOf( 'http://' ) !== -1 || document.URL.indexOf( 'https://' ) !== -1) {
var Notification = window.Notification ||
window.mozNotification ||
window.webkitNotification;

if (Notification.permission !== 'granted') {
Notification.requestPermission();
}
}

eventbus.registerListener('roomMessage', function(roomMessage) {
var message = roomMessage.message;
var senderName = roomMessage.senderName;
var formattedMessage = ChatService.formatMessage(message);

if (!window.cordova && !formattedMessage.isOwner) {
show(senderName, formattedMessage.content);
}
});
eventbus.registerListener('roomMessage', function(roomMessage) {
var message = roomMessage.message;
var senderName = roomMessage.senderName;
var formattedMessage = ChatService.formatMessage(message);

function show(title, message) {
var instance = new Notification(
title, {
body: message,
icon: "img/android-icon-48x48.png"
if (!formattedMessage.isOwner) {
show(senderName, formattedMessage.content);
}
);

instance.onshow = function () {
$timeout(function(){
instance.close();
}, 10000);
};
});

function show(title, message) {
var instance = new Notification(
title, {
body: message,
icon: "img/android-icon-48x48.png"
}
);

instance.onshow = function () {
$timeout(function(){
instance.close();
}, 10000);
};
}
}
});

0 comments on commit ccc42e0

Please sign in to comment.