Skip to content

Commit 56dfbdb

Browse files
authored
Merge pull request #1083 from dpalou/MOBILE-839
Mobile 839
2 parents 7b08b1b + 7c4a78a commit 56dfbdb

File tree

4 files changed

+39
-14
lines changed

4 files changed

+39
-14
lines changed

AppXManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<Logo>assets\StoreLogo.png</Logo>
1515
</Properties>
1616
<Resources>
17-
<Resource Language="en-us" />
17+
<Resource Language="en" />
1818
</Resources>
1919
<Dependencies>
2020
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.14316.0" />

resources/desktop/StoreLogo.png

49.7 KB
Loading

www/core/components/emulator/services/localnotif.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,18 @@ angular.module('mm.core.emulator')
488488
return options;
489489
}
490490

491+
/**
492+
* Function called when a notification is clicked.
493+
*
494+
* @param {Object} notification Clicked notification.
495+
* @return {Void}
496+
*/
497+
function notificationClicked(notification) {
498+
$rootScope.$broadcast('$cordovaLocalNotification:click', notification, 'foreground');
499+
// Focus the app.
500+
require('electron').ipcRenderer.send('focusApp');
501+
}
502+
491503
/**
492504
* Parse a interval and convert it to a number of milliseconds (0 if not valid).
493505
* Code extracted from the Cordova plugin.
@@ -570,20 +582,24 @@ angular.module('mm.core.emulator')
570582

571583
// Listen for click events.
572584
notifInstance.on('activated', function() {
573-
$rootScope.$broadcast('$cordovaLocalNotification:click', notification, 'foreground');
585+
notificationClicked(notification);
574586
});
575587

576-
notifInstance.show()
577-
578-
// Show it in Tile too.
579-
var tileNotif = new winNotif.TileNotification({
580-
tag: notification.id + '',
581-
template: tileTemplate,
582-
strings: [notification.title, notification.text, notification.title, notification.text, notification.title, notification.text],
583-
expirationTime: new Date(Date.now() + mmCoreSecondsHour * 1000) // Expire in 1 hour.
584-
})
588+
notifInstance.show();
585589

586-
tileNotif.show()
590+
try {
591+
// Show it in Tile too.
592+
var tileNotif = new winNotif.TileNotification({
593+
tag: notification.id + '',
594+
template: tileTemplate,
595+
strings: [notification.title, notification.text, notification.title, notification.text, notification.title, notification.text],
596+
expirationTime: new Date(Date.now() + mmCoreSecondsHour * 1000) // Expire in 1 hour.
597+
})
598+
599+
tileNotif.show()
600+
} catch(ex) {
601+
$log.warn('Error showing TileNotification. Please notice they only work with the app installed.', ex);
602+
}
587603
} else {
588604
// Use Electron default notifications.
589605
var notifInstance = new Notification(notification.title, {
@@ -592,7 +608,7 @@ angular.module('mm.core.emulator')
592608

593609
// Listen for click events.
594610
notifInstance.onclick = function() {
595-
$rootScope.$broadcast('$cordovaLocalNotification:click', notification, 'foreground');
611+
notificationClicked(notification);
596612
};
597613
}
598614
}

www/electron.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function createWindow() {
4141

4242
mainWindow.once('ready-to-show', () => {
4343
mainWindow.show();
44+
mainWindow.maximize();
4445
});
4546

4647
// Emitted when the window is closed.
@@ -102,12 +103,18 @@ if (shouldQuit) {
102103

103104
function appLaunched(url) {
104105
// App was launched again with a URL. Focus the main window and send an event to treat the URL.
106+
if (mainWindow) {
107+
focusApp();
108+
mainWindow.webContents.send('mmAppLaunched', url); // Send an event to the main window.
109+
}
110+
}
111+
112+
function focusApp() {
105113
if (mainWindow) {
106114
if (mainWindow.isMinimized()) {
107115
mainWindow.restore();
108116
}
109117
mainWindow.focus();
110-
mainWindow.webContents.send('mmAppLaunched', url); // Send an event to the main window.
111118
}
112119
}
113120

@@ -124,3 +131,5 @@ ipcMain.on('closeSecondaryWindows', () => {
124131
}
125132
}
126133
});
134+
135+
ipcMain.on('focusApp', focusApp);

0 commit comments

Comments
 (0)