I successfully set up a push notification with Ionic and ios. But I want people to click the notification and go to a dynamically pass in state. And I can not figure out how to do it... I am using a node server. First, my state step up is below:
.state('app.task', {
url: "/task/:taskId",
cache: false,
views: {
'menuContent': {
templateUrl: "js/tasks/task-detail.html",
controller: "browseCtrl",
}
},
}
})
And in my node server, I pass in the payload as describe here: Ionic.io Push FAQ
var payload = {"$state":"app.task", "$stateParams": "{\"taskId\": \""+ message.relatedTask +"\"}"};
request({
url: "https://push.ionic.io/api/v1/push",
method: "POST",
json: true,
body: {
"tokens": [token],
"notification": {
"alert": message.message,
"ios": {
"badge":1,
"payload": payload
},
"android": {
"payload": payload
}
}
},
headers: {
'Authorization': 'Basic ' + btoa(IONIC_PRIVATE_API_KEY + ":"),
'X-Ionic-Application-Id': IONIC_APP_ID
}
}, function (error, response, body) {
console.log(body);
})
And when it click the notification, it won't go to the state (just bring me back to the app). The message.relatedTask
is logged as the current taskId. As I can see from XCode console, it logs this:
2015-09-30 18:12:16.488 VideoHappy[1236:403171] Msg: {"$state":"app.task","$stateParams":"{\"taskId\": \"-JzvWR67jIqyfc9JhDMb\"}","$state":"app.task","$stateParams":"{\"taskId\": \"-JzvWR67jIqyfc9JhDMb\"}","badge":"1","body":"Test Title",foreground:"0"}
2015-09-30 18:12:16.600 VideoHappy[1236:403171] $ionicPush:RECEIVED {"$state":"app.task","$stateParams":"{\"taskId\": \"-JzvWR67jIqyfc9JhDMb\"}","badge":"1","body":"Test Title","foreground":"0"}
What did I do wrong?