Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用angularjs和cordova推送通知插件在简历上更改路线的问题_Android_Ios_Angularjs_Cordova_Push Notification - Fatal编程技术网

Android 使用angularjs和cordova推送通知插件在简历上更改路线的问题

Android 使用angularjs和cordova推送通知插件在简历上更改路线的问题,android,ios,angularjs,cordova,push-notification,Android,Ios,Angularjs,Cordova,Push Notification,尝试在应用程序恢复时重新路由;我真的不知道为什么这不起作用。此时将显示恢复警报,并显示主题id。想法 更多详细信息:收到通知后,将存储lastMessage。恢复应用程序时,会检索相关数据,但$location.path()不起作用。对$location.path的相同调用在其他地方也适用 通知工厂内的恢复功能: function onResumeListener() { document.addEventListener('resume', function() { alert("re

尝试在应用程序恢复时重新路由;我真的不知道为什么这不起作用。此时将显示恢复警报,并显示主题id。想法

更多详细信息:收到通知后,将存储lastMessage。恢复应用程序时,会检索相关数据,但$location.path()不起作用。对$location.path的相同调用在其他地方也适用

通知工厂内的恢复功能:

function onResumeListener() {
document.addEventListener('resume', function() {
    alert("resuming");
  var lastMessage;

  try {
    lastMessage = JSON.parse($window.localStorage.getItem('lastMessage'));
      alert(lastMessage.topic_id);
      //$location.path("/chat/" + lastMessage.topic_id);
      //tried putting route change here as well

  } catch (exception) {
      alert("failure");
    lastMessage = '';
  }

    $location.path("/chat/" + lastMessage.topic_id);

});
}
在收到苹果公司的通知时

function onNotificationAPN(e) {
$window.localStorage.setItem('lastMessage', JSON.stringify(e));
$rootScope.$broadcast('push.message', e);

if (e.alert) {}
if (e.sound) {}
if (e.badge) {}
}
function onNotificationGCM(e) {
$window.localStorage.setItem('lastMessage', JSON.stringify(e));

switch (e.event) {
  case 'registered':
    localStorage.setItem('deviceId', e.regid);
    $rootScope.$broadcast('push.register', e.regid);
    break;
  case 'message':
    //alert('broadcast');
    $rootScope.$broadcast('push.message', e);
    break;
  case 'error':
    $log.error('Error event received: ' + e);
    break;
  default:
    $log.error('Unknown event received: ' + e);
    break;
}
}
关于接收android通知

function onNotificationAPN(e) {
$window.localStorage.setItem('lastMessage', JSON.stringify(e));
$rootScope.$broadcast('push.message', e);

if (e.alert) {}
if (e.sound) {}
if (e.badge) {}
}
function onNotificationGCM(e) {
$window.localStorage.setItem('lastMessage', JSON.stringify(e));

switch (e.event) {
  case 'registered':
    localStorage.setItem('deviceId', e.regid);
    $rootScope.$broadcast('push.register', e.regid);
    break;
  case 'message':
    //alert('broadcast');
    $rootScope.$broadcast('push.message', e);
    break;
  case 'error':
    $log.error('Error event received: ' + e);
    break;
  default:
    $log.error('Unknown event received: ' + e);
    break;
}
}

我也遇到了同样的问题,并通过在超时时间内包装位置更改来解决它(有点麻烦):

$timeout(function(){$location.path('/yourPath')},0);

我不知道为什么它解决了这个问题(至少对我来说),但我想可能是当你点击通知并在下一个空闲时间(超时0)推迟位置更改时,完整的角度功能不可用。也可能是(额外的)应用,
$timeout
发送完成了这项任务…

我也遇到了同样的问题,并通过将位置更改包装在超时中解决了它(有点麻烦):

$timeout(function(){$location.path('/yourPath')},0);

我不知道为什么它解决了这个问题(至少对我来说),但我想可能是当你点击通知并在下一个空闲时间(超时0)推迟位置更改时,完整的角度功能不可用。也可能是(额外的)应用,
$timeout
发送的消息会起作用……

您找到解决方案了吗?我和我的团队遇到了同样的问题,我最终找到了解决方案,但我不记得到底是什么。但不要认为我们使用了超时。你找到解决方案了吗?我和我的团队遇到了同样的问题,我最终找到了解决方案,但我不记得到底是什么。但别以为我们用了暂停。