I used to use this data array in my PHP-script to send notification data for an Ionic app.
$data = array(
'user_ids' => ['...','...'],
'notification' => array
(
'alert' => $notif_msg,
"android" => array
(
'title' => $notif_title,
"payload" => array
(
"msg" => $popup_msg,
"msg_title" => $popup_title,
"notif_type" => $type
)
)
)
);
In my app, I take this data using:
"onNotification": function(notification) {
var payload = notification.payload;
var notif_type = payload.msg;
...
$ionicPopup.alert({
title: payload.msg_title, // String. The title of the popup.
template: payload.msg, // String (optional). The html template to place in the popup body.
okText: '', // String (default: 'OK'). The text of the OK button.
okType: 'button-assertive' // String (default: 'button-positive'). The type of the OK button.
});
...
Now, I want to send multiple data, like so:
$data = array(
'user_ids' => ['...','...'],
'notification' => array
(
'alert' => $notif_msg,
"android" => array
(
'title' => $notif_title,
"payload" => array
(
"notif_type" => $type,
0 => array("msg" => $popup_msg,
"msg_title" => $popup_title,
"notif_type" => $type),
1 => array("msg" => $popup_msg,
"msg_title" => $popup_title,
"notif_type" => $type),
)
)
)
);
But I’m unable to display the different msg’s… This is my code:
var payload = notification.payload;
$scope.notif = payload;
$ionicPopup.alert({
title: payload.msg_title, // String. The title of the popup.
template: "<div ng-repeat='n in notif'>{{n.msg}}</div>", // String (optional). The html template to place in the popup body.
okText: '', // String (default: 'OK'). The text of the OK button.
okType: 'button-assertive' // String (default: 'button-positive'). The type of the OK button.
});
Anyone knows what I’m doing wrong?