![](/img/trans.png)
[英]How can i add text in “$cordovaLocalNotification.schedule” for multiple ngCordova local notification dynamically?
[英]I have ngCordova local notification working, how can i make it trigger for every user
我有一个带textarea的ionicPopup,用户输入文本时,将其保存在firebase中。 更改此值后,将无法在用户输入数据的手机上触发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");
});
});
};
}]);
可以使用
firebaseRef.on('value', function(){
local notification scheduling
});
有2个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.