Improved FxOS 1.1 PUSH notifications
Closes #413 Closes #373 Closes #441
This commit is contained in:
parent
da6b82ae8f
commit
ab1795dbbe
@ -351,8 +351,6 @@ angular.module('myApp.services', [])
|
|||||||
|
|
||||||
.service('PhonebookContactsService', function ($q, $modal, $sce, FileManager) {
|
.service('PhonebookContactsService', function ($q, $modal, $sce, FileManager) {
|
||||||
|
|
||||||
var phonebookContactsPromise;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isAvailable: isAvailable,
|
isAvailable: isAvailable,
|
||||||
openPhonebookImport: openPhonebookImport,
|
openPhonebookImport: openPhonebookImport,
|
||||||
@ -380,10 +378,6 @@ angular.module('myApp.services', [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPhonebookContacts () {
|
function getPhonebookContacts () {
|
||||||
if (phonebookContactsPromise) {
|
|
||||||
return phonebookContactsPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var request = window.navigator.mozContacts.getAll({});
|
var request = window.navigator.mozContacts.getAll({});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -435,7 +429,7 @@ angular.module('myApp.services', [])
|
|||||||
deferred.reject(e);
|
deferred.reject(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return phonebookContactsPromise = deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -3489,10 +3483,7 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function notify (data) {
|
function notify (data) {
|
||||||
// console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport);
|
console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport);
|
||||||
if (!$rootScope.idle.isIDLE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FFOS Notification blob src bug workaround
|
// FFOS Notification blob src bug workaround
|
||||||
if (Config.Navigator.ffos) {
|
if (Config.Navigator.ffos) {
|
||||||
@ -3558,6 +3549,9 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
|||||||
notificationsClear();
|
notificationsClear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (notification.show) {
|
||||||
|
notification.show();
|
||||||
|
}
|
||||||
notificationsShown[key] = notification;
|
notificationsShown[key] = notification;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -3598,6 +3592,8 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
|||||||
notificationsCount = 0;
|
notificationsCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var registerDevicePeriod = 1000,
|
||||||
|
registerDeviceTO;
|
||||||
function registerDevice () {
|
function registerDevice () {
|
||||||
if (registeredDevice) {
|
if (registeredDevice) {
|
||||||
return false;
|
return false;
|
||||||
@ -3606,6 +3602,8 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
|||||||
var req = navigator.push.register();
|
var req = navigator.push.register();
|
||||||
|
|
||||||
req.onsuccess = function(e) {
|
req.onsuccess = function(e) {
|
||||||
|
clearTimeout(registerDeviceTO);
|
||||||
|
console.log(dT(), 'Push registered', req.result);
|
||||||
registeredDevice = req.result;
|
registeredDevice = req.result;
|
||||||
MtpApiManager.invokeApi('account.registerDevice', {
|
MtpApiManager.invokeApi('account.registerDevice', {
|
||||||
token_type: 4,
|
token_type: 4,
|
||||||
@ -3619,7 +3617,9 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
|||||||
}
|
}
|
||||||
|
|
||||||
req.onerror = function(e) {
|
req.onerror = function(e) {
|
||||||
console.error('Push register error', e);
|
console.error('Push register error', e, e.toString());
|
||||||
|
registerDeviceTO = setTimeout(registerDevice, registerDevicePeriod);
|
||||||
|
registerDevicePeriod = Math.min(30000, registerDevicePeriod * 1.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
"push": "/index.html"
|
"push": "/index.html"
|
||||||
}, {
|
}, {
|
||||||
"push-register": "/index.html"
|
"push-register": "/index.html"
|
||||||
|
}, {
|
||||||
|
"notification": "/index.html"
|
||||||
}],
|
}],
|
||||||
"permissions": {
|
"permissions": {
|
||||||
"desktop-notification": {
|
"desktop-notification": {
|
||||||
@ -28,6 +30,7 @@
|
|||||||
"description": "Required for notifications"
|
"description": "Required for notifications"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"orientation": "portrait-primary",
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "/img/icons/icon16.png",
|
"16": "/img/icons/icon16.png",
|
||||||
"32": "/img/icons/icon32.png",
|
"32": "/img/icons/icon32.png",
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
Sorry, there are no <strong>Telegram</strong> accounts with the phone numbers you provided.
|
Sorry, there are no <strong>Telegram</strong> accounts with the phone numbers you provided.
|
||||||
</span>
|
</span>
|
||||||
<span ng-switch-when="PHONEBOOK_GET_CONTACTS_FAILED">
|
<span ng-switch-when="PHONEBOOK_GET_CONTACTS_FAILED">
|
||||||
Telegram need access to phonebook to import contacts.
|
Telegram needs access to phonebook to import contacts.
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div ng-switch-default ng-switch="error.code">
|
<div ng-switch-default ng-switch="error.code">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user