这是我的配置文件
(function () {
'use strict';
angular
.module('app.core')
.config(['$ionicConfigProvider', '$httpProvider', '$compileProvider', function ($ionicConfigProvider, $httpProvider, $compileProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top
$compileProvider.debugInfoEnabled(false); // remove while debugging
$httpProvider.interceptors.push('authInterceptorService');
document.addEventListener('deviceready', function ($state) {
var notificationOpenedCallback = function (jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
window.plugins.OneSignal.init("xxxxx-xxxxxx-xxxxxx-xxxx",
{ googleProjectNumber: "xxxxxxxxx" },
notificationOpenedCallback);
window.plugins.OneSignal.getIds(function (ids) {
var deviceId = ids;
console.log(deviceId);
localStorage.setItem('deviceId', deviceId.userId);
});
// Show an alert box if a notification comes in when the user is in your app.
window.plugins.OneSignal.enableInAppAlertNotification(true);
}, false);
}]);
})();
在点击设备选项卡上堆叠的推送消息时会发生notificationOpenedCallback。所以我想转到特定路线,而不是只打开它现在正在执行的应用程序。 在我的notificationOpenedCallback函数中,我希望能够路由到特定的状态,如
.state('tabs.answered', {
url: "/answered",
views: {
'tab-answered': {
templateUrl: "app/answeredfeed/answered.html",
controller: 'AnsweredCtrl',
controllerAs: 'vm'
}
},
authRequired: true
});
通常我会做一个
$state.go('tabs.answered');
但问题是我无法注入$ state或$ stateprovider以便我可以路由到tabs.answered。是否有可能从配置路由或我弄错了?这个功能可以通过其他方式完成吗?
答案 0 :(得分:2)
将angular.config更改为angular.run,我能够注入$ injector 因此可以做一个
onKeyDown(int, KeyEvent)