$stateParams getting lost when calling $state.go from a background/cold start push notification

Hi there! I’m relatively new to the Ionic framework, and I love it so far!

But I’m completely stumped on how to call $state.go using $stateParams so a background/cold start push notification will open up a particular page to a particular message ID. In my onNotification() function, I’m logging the payload of the push notification, so I know the state name and $stateParams are being passed into that properly. But somewhere between the call to $state.go(‘message’, {id: ‘12345’}) and where the new state gets initialized, the $stateParams object is turning from {id: ‘12345’} to {id: null}.

Foreground notifications work just fine, so I assume that the problem has something to do with the extra initialization that happens when opening the app from a push notification.

Here’s my $ionicPush.register call (it’s Coffeescript, sorry… let me know if you need JS):

$ionicPush.register
  canShowAlert: true
  canSetBadge: true
  canPlaySound: true
  canRunActionsOnWake: true
  onNotification: (notification) ->
    ionic.Platform.ready ->
      console.log(notification)
      if notification.event == 'message'
        # alert(JSON.stringify(notification))
        if notification.payload?.payload?
          payload = notification.payload.payload
          if payload.$state? && payload.$stateParams?
            $state.go(payload.$state, payload.$stateParams)
    return true

Again, this only works when the app is in the foreground. It does not work when the app is in the background, or when it is completely closed (cold start). What am I missing?

Thanks so much for your help!!

@chrisguida Did you ever find a workaround for this? I’d like to do the same thing and finding it difficult to read the notification.payload value in iOS 9 using the ionic-platform-web-client as described in Push from scratch tutorial (http://docs.ionic.io/docs/push-from-scratch). Thanks!