Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 836737 - we should not launch the app when we close a notificatio…
Browse files Browse the repository at this point in the history
…n r=vingtetun a=tef+

We'll receive a notification if the user clicks on the notif or if he closes it,
but we want to do stuff only when the user clicks on it.

The gecko patch needs to land first.
  • Loading branch information
julienw authored and jhford committed Feb 14, 2013
1 parent 6544fdb commit 9eb15be
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
6 changes: 5 additions & 1 deletion apps/communications/dialer/js/dialer.js
Expand Up @@ -49,7 +49,11 @@ var CallHandler = (function callHandler() {
window.navigator.mozSetMessageHandler('activity', handleActivity);

/* === Notifications support === */
function handleNotification() {
function handleNotification(evt) {
if (!evt.clicked) {
return;
}

navigator.mozApps.getSelf().onsuccess = function gotSelf(evt) {
var app = evt.target.result;
app.launch('dialer');
Expand Down
7 changes: 6 additions & 1 deletion apps/costcontrol/js/app.js
Expand Up @@ -114,7 +114,12 @@ var CostControlApp = (function() {
// When a notification is received
window.navigator.mozSetMessageHandler('notification',
function _onNotification(notification) {
debug('Notification received!');
if (!notification.clicked) {
return;
}

debug('Notification was clicked!');

navigator.mozApps.getSelf().onsuccess = function _onAppReady(evt) {
var app = evt.target.result;
app.launch();
Expand Down
37 changes: 21 additions & 16 deletions apps/sms/js/sms.js
Expand Up @@ -1745,23 +1745,28 @@ if (!window.location.hash.length) {

window.navigator.mozSetMessageHandler('notification',
function notificationClick(message) {
navigator.mozApps.getSelf().onsuccess = function(evt) {
var app = evt.target.result;
app.launch();

// Getting back the number form the icon URL
var notificationType = message.imageURL.split('?')[1];
// Case regular 'sms-received'
if (notificationType == 'sms-received') {
var number = message.imageURL.split('?')[2];
showThreadFromSystemMessage(number);
if (!message.clicked) {
return;
}
var number = message.title;
// Class 0 message
var messageBody = number + '\n' + message.body;
alert(messageBody);
};
});

navigator.mozApps.getSelf().onsuccess = function(evt) {
var app = evt.target.result;
app.launch();

// Getting back the number form the icon URL
var notificationType = message.imageURL.split('?')[1];
// Case regular 'sms-received'
if (notificationType == 'sms-received') {
var number = message.imageURL.split('?')[2];
showThreadFromSystemMessage(number);
return;
}
var number = message.title;
// Class 0 message
var messageBody = number + '\n' + message.body;
alert(messageBody);
};
}
);
}

0 comments on commit 9eb15be

Please sign in to comment.