push notifications
This commit is contained in:
parent
b3c59e2cb0
commit
fdc03a6f29
3 changed files with 67 additions and 1 deletions
|
|
@ -106,6 +106,12 @@ if [ ! -d $PROJECT ]; then
|
|||
cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=bitcoin
|
||||
checkOK
|
||||
|
||||
cordova plugin add phonegap-plugin-push@1.2.3
|
||||
checkOK
|
||||
|
||||
cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=bitcoin
|
||||
checkOK
|
||||
|
||||
cordova plugin add cordova-plugin-inappbrowser
|
||||
checkOK
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService, isMobile, addressbookService) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService, isMobile, addressbookService) {
|
||||
var self = this;
|
||||
var SOFT_CONFIRMATION_LIMIT = 12;
|
||||
self.isCordova = isCordova;
|
||||
|
|
@ -11,6 +11,52 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.updatingTxHistory = {};
|
||||
self.prevState = 'walletHome';
|
||||
|
||||
document.addEventListener('deviceready', function() {
|
||||
|
||||
var push = PushNotification.init({
|
||||
android: {
|
||||
senderID: "959259672122"
|
||||
},
|
||||
ios: {
|
||||
alert: "true",
|
||||
badge: true,
|
||||
sound: 'false'
|
||||
},
|
||||
windows: {}
|
||||
});
|
||||
|
||||
push.on('registration', function(data) {
|
||||
var opts = {};
|
||||
opts.user = "Gabriel";
|
||||
opts.type = "android";
|
||||
opts.token = data.registrationId;
|
||||
pushNotificationsService.subscribe(opts).then(function(response) {
|
||||
console.log(response);
|
||||
},
|
||||
function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
push.on('notification', function(data) {
|
||||
console.log("notification event");
|
||||
alert(data.message);
|
||||
|
||||
// data.message,
|
||||
// data.title,
|
||||
// data.count,
|
||||
// data.sound,
|
||||
// data.image,
|
||||
// data.additionalData
|
||||
});
|
||||
|
||||
push.on('error', function(e) {
|
||||
console.log("error pushhhhhh");
|
||||
alert(e.message);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function strip(number) {
|
||||
return (parseFloat(number.toPrecision(12)));
|
||||
};
|
||||
|
|
|
|||
14
src/js/services/pushNotificationsService.js
Normal file
14
src/js/services/pushNotificationsService.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.services')
|
||||
.factory('pushNotificationsService', function($http) {
|
||||
var root = {};
|
||||
|
||||
//"APA91bHCysW7fzE_ks5HPOu2BGr0G7T-aD5SPfzaSGIKuhp82gFUcopVPPck8EfnxgHyK_3QJ9FdFS8H2mjAILDv3jdrH6slJzmCwoszya9XdJz4Uv-cxkLDYXb7z086TD3uPgSLnMUO"
|
||||
|
||||
root.subscribe = function(opts) {
|
||||
return $http.post('http://192.168.1.120:8000/subscribe', opts);
|
||||
}
|
||||
|
||||
return root;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue