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) {
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ’ + JSON.stringify(jsonData));
if (jsonData.additionalData && jsonData.additionalData.targetUrl) {
var state = $injector.get($state);
window.plugins.OneSignal.init(“MY-API_KEY”, {
googleProjectNumber: “MY-GOOGLE-PROJECT-NUMBER”,
autoRegister: true
notificationOpenedCallback({title: ‘test’}));
// oneSignal.init();
if (window.StatusBar) {
// org.apache.cordova.statusbar required
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
Node Version: v4.4.1


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);

    // Update with your OneSignal AppId and googleProjectNumber before running.
    .init(ONESIGNAL_APP_ID, {
            googleProjectNumber: GOOGLE_PROJECT_NUMBER

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