繁体   English   中英

我有ngCordova本地通知正在运行,如何使它触发给每个用户

[英]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个问题。

  1. 也在消息发件人一侧触发通知。
  2. 当应用程序的状态为“后台”时,通知失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM