0
我有一個用textarea的ionicPopup,當用戶輸入文本時,保存在firebase中。在這種價值變化無法觸發ngCordova本地用戶輸入數據的移動設備上的通知。 我如何使這個值更改觸發每個登錄用戶的手機相同的通知。我有ngCordova本地通知工作,我怎麼能讓它觸發每個用戶
服務:
servicesModule.factory("Profile", ["$firebaseObject",
function($firebaseObject) {
return function(new_value) {
var ref = new Firebase("https://feedback-system.firebaseio.com/Courses/" + 'newValue');
var new_value_ref = ref.child(new_value);
return $firebaseObject(new_value_ref);
}
}
]);
控制器:
var ionicApp = angular.module('localNotificationModule', ['ionic', 'ngCordova']);
ionicApp.controller('localNotificationCtrl', ['$scope', '$rootScope', '$ionicPlatform', '$cordovaLocalNotification', '$state', 'Profile', '$firebase', 'Firebase', function($scope, $rootScope, $ionicPlatform, $cordovaLocalNotification, $state, Profile, $firebase, Firebase){
$scope.profile = Profile("physicsmarie");
// calling $save() on the synchronized object syncs all data back to our Firebase database
$scope.testNotification = function() {
$scope.profile.$save().then(function() {
scheduleDelayedNotification($scope.profile.name);
}).catch(function(error) {
alert('Error!');
});
};
function scheduleDelayedNotification(newValue) {
$ionicPlatform.ready(function() {
$cordovaLocalNotification.schedule({
id: 1,
title: 'New Notification',
text: newValue,
autoCancel: true
}).then(function (result) {
alert("Notification Set");
});
});
};
}]);