@zivonia wrote:
alert said New post Name:undefined
// console.log(notification, payload); get following data : { "message":"POst Title", "additionalData":{ "foreground":true, "collapse_key":"do_not_collapse" }, "title":"appName" }
i've send the notification and i didn't get the payload correctly exactly the id of post to redirect the user directly to the new post here's my couple of codes that i add :
The payload :
$payload = array( 'title' => $title, 'url' => get_permalink($post), 'id' => get_the_ID($post), 'author' => get_the_author_meta('display_name', $post->post_author) );
// -------------------
// the data that supposed to sent (server side):
$data = array( 'user_ids' => $userIds, 'notification' => array('alert' => $text), 'ios' => array( 'payload' => $payload ), 'android' => array( 'payload' => $payload ) );
// ------------------------
// Client side(app) :
// Here is the goItem function: $rootScope.goItem = function(index) { alert('Go Item ' + index); $state.go('postDetail', { "postId": index }); $rootScope.currentPage = "postDetail"; } var io = Ionic.io(); var push = new Ionic.Push({ "onNotification": function(notification) { if (ionic.Platform.isAndroid() && notification.payload){ var payload = notification.payload; alert('New post Name: '+payload.title); // $state.go('/main/contentRecent'); // console.log(notification, payload); } // $rootScope.goItem(notification.playload.id); }, "pluginConfig": { "android": { "iconColor": "#0000FF" } } });
Posts: 1
Participants: 1