aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/app/Application.js13
-rw-r--r--web/app/controller/Root.js8
-rw-r--r--web/l10n/en.json1
-rw-r--r--web/load.js4
4 files changed, 26 insertions, 0 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index d0b6713c..a4cbbf22 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -148,6 +148,19 @@ Ext.define('Traccar.Application', {
}
},
+ updateNotificationToken: function (token) {
+ var attributes = Ext.clone(this.user.get('attributes'));
+ if (!attributes.notificationTokens || attributes.notificationTokens.indexOf(token) < 0) {
+ if (!attributes.notificationTokens) {
+ attributes.notificationTokens = token;
+ } else {
+ attributes.notificationTokens += ',' + token;
+ }
+ this.user.set('attributes', attributes);
+ this.user.save();
+ }
+ },
+
setUser: function (data) {
var reader = Ext.create('Ext.data.reader.Json', {
model: 'Traccar.model.User'
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 0edc049a..7c0345ad 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -109,6 +109,14 @@ Ext.define('Traccar.controller.Root', {
loadApp: function () {
var attribution, eventId;
+
+ if (window.webkit && window.webkit.messageHandlers.appInterface) {
+ window.webkit.messageHandlers.appInterface.postMessage('login');
+ }
+ if (window.appInterface) {
+ window.appInterface.postMessage('login');
+ }
+
Ext.getStore('Groups').load();
Ext.getStore('Drivers').load();
Ext.getStore('Geofences').load();
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 5acc1ea1..05e0d1b4 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -360,6 +360,7 @@
"notificatorWeb": "Web",
"notificatorMail": "Mail",
"notificatorSms": "SMS",
+ "notificatorFirebase": "Mobile",
"reportRoute": "Route",
"reportEvents": "Events",
"reportTrips": "Trips",
diff --git a/web/load.js b/web/load.js
index 0418a131..552b167a 100644
--- a/web/load.js
+++ b/web/load.js
@@ -28,6 +28,10 @@
debugMode = document.getElementById('loadScript').getAttribute('mode') === 'debug';
touchMode = 'ontouchstart' in window || navigator.maxTouchPoints;
+ window.updateNotificationToken = function (token) {
+ Traccar.app.updateNotificationToken(token);
+ };
+
locale = {};
window.Locale = locale;