Open wallet on tap notification
This commit is contained in:
parent
b73d51f194
commit
18d28d264b
1 changed files with 13 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('copayApp.services').factory('pushNotificationsService', function pushNotificationsService($log, $state, $ionicHistory, platformInfo, lodash, appConfigService, profileService, configService) {
|
angular.module('copayApp.services').factory('pushNotificationsService', function pushNotificationsService($log, $state, $ionicHistory, sjcl, platformInfo, lodash, appConfigService, profileService, configService) {
|
||||||
var root = {};
|
var root = {};
|
||||||
var isIOS = platformInfo.isIOS;
|
var isIOS = platformInfo.isIOS;
|
||||||
var isAndroid = platformInfo.isAndroid;
|
var isAndroid = platformInfo.isAndroid;
|
||||||
|
|
@ -72,17 +72,22 @@ angular.module('copayApp.services').factory('pushNotificationsService', function
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var _openWallet = function(walletId) {
|
var _openWallet = function(walletIdHashed) {
|
||||||
var wallet = profileService.getWallet(walletId);
|
var wallets = profileService.getWallets();
|
||||||
|
var wallet = lodash.find(wallets, function(w) {
|
||||||
|
return (lodash.isEqual(walletIdHashed, sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(w.id))));
|
||||||
|
});
|
||||||
|
|
||||||
if (!wallet) return;
|
if (!wallet) return;
|
||||||
|
|
||||||
if (!wallet.isComplete()) {
|
if (!wallet.isComplete()) {
|
||||||
return $state.go('tabs.copayers', {
|
return $state.go('tabs.copayers', {
|
||||||
walletId: walletId
|
walletId: wallet.id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$state.go('tabs.wallet', {
|
$state.go('tabs.wallet', {
|
||||||
walletId: walletId
|
walletId: wallet.id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -100,15 +105,15 @@ angular.module('copayApp.services').factory('pushNotificationsService', function
|
||||||
$log.debug('New Event Push onNotification: ' + JSON.stringify(data));
|
$log.debug('New Event Push onNotification: ' + JSON.stringify(data));
|
||||||
if(data.wasTapped) {
|
if(data.wasTapped) {
|
||||||
// Notification was received on device tray and tapped by the user.
|
// Notification was received on device tray and tapped by the user.
|
||||||
var walletId = data.walletId;
|
var walletIdHashed = data.walletId;
|
||||||
if (!walletId) return;
|
if (!walletIdHashed) return;
|
||||||
$ionicHistory.nextViewOptions({
|
$ionicHistory.nextViewOptions({
|
||||||
disableAnimate: true,
|
disableAnimate: true,
|
||||||
historyRoot: true
|
historyRoot: true
|
||||||
});
|
});
|
||||||
$ionicHistory.clearHistory();
|
$ionicHistory.clearHistory();
|
||||||
$state.go('tabs.home').then(function() {
|
$state.go('tabs.home').then(function() {
|
||||||
_openWallet(walletId);
|
_openWallet(walletIdHashed);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue