Added device register for packaged FFOS app
This commit is contained in:
parent
45f3798794
commit
62a905f087
@ -256,12 +256,17 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
||||
|
||||
console.log(dT(), 'PQ factorization start', auth.pq);
|
||||
if (!!window.Worker/* && false*/) {
|
||||
var worker = new Worker('js/lib/pq_worker.js');
|
||||
var worker = new Worker('js/lib/pq_worker.js'),
|
||||
curRetry = auth.pqRetry,
|
||||
canceled = false;
|
||||
|
||||
worker.onmessage = function (e) {
|
||||
auth.p = e.data[0];
|
||||
auth.q = e.data[1];
|
||||
console.log(dT(), 'PQ factorization done', e.data[2]);
|
||||
} catch (e) {
|
||||
alert(e.message + ' ' + e.stack);
|
||||
}
|
||||
mtpSendReqDhParams(auth);
|
||||
};
|
||||
worker.onerror = function(error) {
|
||||
@ -288,6 +293,11 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
||||
};
|
||||
|
||||
function mtpSendReqDhParams (auth) {
|
||||
|
||||
alert('send req dh');
|
||||
alert(auth.p);
|
||||
alert(auth.q);
|
||||
|
||||
var deferred = auth.deferred;
|
||||
|
||||
auth.newNonce = new Array(32);
|
||||
|
@ -3279,6 +3279,7 @@ angular.module('myApp.services', [])
|
||||
}
|
||||
|
||||
function start () {
|
||||
registerDevice();
|
||||
if (!notificationsUiSupport) {
|
||||
return false;
|
||||
}
|
||||
@ -3389,6 +3390,46 @@ angular.module('myApp.services', [])
|
||||
});
|
||||
notificationsShown = {};
|
||||
}
|
||||
|
||||
var registeredDevice = false;
|
||||
|
||||
function registerDevice () {
|
||||
if (registeredDevice) {
|
||||
return false;
|
||||
}
|
||||
if (navigator.push) {
|
||||
var req = navigator.push.register();
|
||||
|
||||
req.onsuccess = function(e) {
|
||||
registeredDevice = req.result;
|
||||
MtpApiManager.invokeApi('account.registerDevice', {
|
||||
token_type: 4,
|
||||
token: registeredDevice,
|
||||
device_model: navigator.userAgent || 'Unknown UserAgent',
|
||||
system_version: navigator.platform || 'Unknown Platform',
|
||||
app_version: Config.App.version,
|
||||
app_sandbox: false,
|
||||
lang_code: navigator.language || 'en'
|
||||
});
|
||||
}
|
||||
|
||||
req.onerror = function(e) {
|
||||
console.error('Push register error', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unregisterDevice () {
|
||||
if (!registeredDevice) {
|
||||
return false;
|
||||
}
|
||||
MtpApiManager.invokeApi('account.unregisterDevice', {
|
||||
token_type: 4,
|
||||
token: registeredDevice
|
||||
}).then(function () {
|
||||
registeredDevice = false;
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
@ -11,6 +11,11 @@
|
||||
"installs_allowed_from": [
|
||||
"*"
|
||||
],
|
||||
"messages": [{
|
||||
"push": "/index.html"
|
||||
}, {
|
||||
"push-register": "/index.html"
|
||||
}],
|
||||
"permissions": {
|
||||
"desktop-notification": {
|
||||
"description": "Required to show new message notifications"
|
||||
@ -18,6 +23,9 @@
|
||||
"contacts": {
|
||||
"description": "Required to import phonebook contacts",
|
||||
"access": "readonly"
|
||||
},
|
||||
"push": {
|
||||
"description": "Required for notifications"
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user