Sending user to a specific view is working on clicking a local notification but only when app is in foreground, when i close app and get notification then it send on to the main page only which is defined in
$urlRouterProvider.otherwise("/");
for example, when we are not using WhatsApp and we get a new message notification and when we click it, it send us to that specific chat page not the main page of whatsapp, how can i achieve it?
controller:
$ionicPlatform.ready(function () {
$scope.scheduleDelayedNotification = function () {
var now = new Date().getTime();
var _5_SecondsFromNow = new Date(now + 5 * 1000);
$cordovaLocalNotification.schedule({
id: 1,
title: 'New Notification',
text: 'Notification Message',
at: _5_SecondsFromNow
}).then(function (result) {
alert("Notification Set");
});
cordova.plugins.notification.local.on("click", function (notification, state) {
$state.go('feedback');
}, this)
};
});
app.js
var ionicApp = angular.module('starter', ['ionic', 'localNotificationModule']);
ionicApp.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
});
ionicApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'views/home.html'
})
.state('feedback', {
url: '/feedback',
templateUrl: 'views/feedback.html'
});
$urlRouterProvider.otherwise("/");
});