OneSignal CallBack function not fired on Opening Notification

am using Ionic Framework. I have successfully registered and able to receive the notifications. But my callback function is not being called when I open a notification. It just gets called on the first init(). I have placed the code in the app.js run function() after device is ready. I searched a few forums but I could not find any solution. Below is the code:

$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 && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ’ + JSON.stringify(jsonData));
if (jsonData.additionalData && jsonData.additionalData.targetUrl) {
var state = $injector.get($state);
$state.go(jsonData.additionalData.targetUrl);
}
};
window.plugins.OneSignal.init(“MY-API_KEY”, {
googleProjectNumber: “MY-GOOGLE-PROJECT-NUMBER”,
autoRegister: true
},
notificationOpenedCallback({title: ‘test’}));
window.plugins.OneSignal.setSubscription(true);
window.plugins.OneSignal.enableNotificationsWhenActive(true);
// oneSignal.init();
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
The callback function is fired only when the app starts the first time and init is called. When I open a received notification the callback function is not fired. I am doing this just for android. Can anybody please help me out?

Below are the ionic info:
Cordova CLI: 6.2.0
Gulp version: CLI version 3.9.0
Gulp local:
Ionic Framework Version: 1.2.4
Ionic CLI Version: 1.7.15
Ionic App Lib Version: 0.7.2
OS:
Node Version: v4.4.1

Thanks

It was solved by removing function call in init, need to just pass function name

can u please help me i can’t go to post link after click in notification

.run(function($ionicPlatform, $state, ONESIGNAL_APP_ID, GOOGLE_PROJECT_NUMBER, $rootScope, $ionicHistory) {
$ionicPlatform.ready(function() {
// Add additional data (data field in the REST API) when you send your notification with yourUrlKey equal to the url you want to navigate to.
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ’ + JSON.stringify(jsonData));
if (jsonData.additionalData && jsonData.additionalData.postid) {
var state = $injector.get($state);
$state.go(jsonData.additionalData.postid);
}
};

    // Update with your OneSignal AppId and googleProjectNumber before running.
    window.plugins.OneSignal
    .init(ONESIGNAL_APP_ID, {
            googleProjectNumber: GOOGLE_PROJECT_NUMBER
        },
        notificationOpenedCallback);

Onesignal has updated their documentation with new INIT methods.
refer here