You can broadcast the event in notificationOpenedCallback :
var notificationOpenedCallback = function(jsonData) { //alert("Notification received:\n" + JSON.stringify(jsonData)); //console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData)); $rootScope.openedFromNotification = true; alert($rootScope.openedFromNotification); // $ionicHistory.clearCache(); // $window.location.reload(true); $rootScope.$broadcast('app:notification', {refresh: true}); };
As you can see, I created a custom app:notification event and used $rootScope to broadcast it ( $broadcast ) in the area with children.
I added an object with information that your receiver can use.
Now in your controller you can intercept the event using $scope.$on and call the update function:
angular.module('starter.controllers',['ionic']) .controller('MainCtrl', function($scope, $rootScope, $http) { $scope.$on('app:notification', function(event, data) { console.log(data); if (data.refresh) { $scope.doRefresh(); } }); });
NOTES:
You do not need to clear the cache here $ionicHistory.clearCache(); .
source share