Added firebase events service and added it to the home tab
This commit is contained in:
parent
ccc0dc10a1
commit
b1cfa65a6e
2 changed files with 36 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService, pushNotificationsService, timeService, bitcoincomService, pricechartService) {
|
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService, pushNotificationsService, timeService, bitcoincomService, pricechartService, firebaseEventsService) {
|
||||||
var wallet;
|
var wallet;
|
||||||
var listeners = [];
|
var listeners = [];
|
||||||
var notifications = [];
|
var notifications = [];
|
||||||
|
|
@ -122,6 +122,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
}
|
}
|
||||||
|
|
||||||
pushNotificationsService.init();
|
pushNotificationsService.init();
|
||||||
|
firebaseEventsService.init();
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$ionicScrollDelegate.resize();
|
$ionicScrollDelegate.resize();
|
||||||
|
|
|
||||||
33
src/js/services/firebaseEventsService.js
Normal file
33
src/js/services/firebaseEventsService.js
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
'use strict';
|
||||||
|
angular.module('copayApp.services').factory('firebaseEventsService', function firebaseEventsService($log, $state, $ionicHistory, sjcl, platformInfo, lodash, appConfigService, profileService, configService) {
|
||||||
|
var root = {};
|
||||||
|
var useEvents = platformInfo.isCordova && !platformInfo.isWP;
|
||||||
|
|
||||||
|
var _token = null;
|
||||||
|
|
||||||
|
root.init = function() {
|
||||||
|
if (!useEvents || _token) return;
|
||||||
|
$log.debug('Starting event registration...');
|
||||||
|
|
||||||
|
FirebasePlugin.getToken(function(token) {
|
||||||
|
$log.debug('Get token for events: ' + token);
|
||||||
|
_token = token;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
root.logEvent = function(eventName, params) {
|
||||||
|
if (!_token) return;
|
||||||
|
var p = params ? params : {};
|
||||||
|
FirebasePlugin.logEvent(eventName, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useEvents) {
|
||||||
|
FirebasePlugin.onTokenRefresh(function(token) {
|
||||||
|
if (!token) return;
|
||||||
|
$log.debug('Refresh and update token for events...');
|
||||||
|
_token = token;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return root;
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue