这是我的配置文件
(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 。甚至可以从配置路由还是我都错了?可以通过其他方式完成此功能吗?