0
我一直在成功地通過PHP發送數據到服務器,並獲得android設備的notificataion。如何從返回jsonData中讀取數據與科爾多瓦的OneSignal推送通知
PHP代碼:
function sendMessage(){
$content = array(
"en" => 'English Message'
);
$fields = array(
'app_id' => "5eb5a37e-b458-11e3-ac11-000c2940e62c",
'included_segments' => array('All'),
'data' => array("foo" => "bar"), ---> I want to access this
'contents' => $content
);
科爾多瓦Android處理通知接收:
window.plugins.OneSignal
.startInit("xxxxxxxxxxx", "xxxxxxxx")
.handleNotificationReceived(function(jsonData) {
alert("Notification received:\n" + JSON.stringify(jsonData));
// alert(jsonData.payload.additionalData.foo) -> error
})
.endInit();
從jsonData我想訪問array("foo" => "bar")
。在另一個線程使用jsonData.payload.additionalData
,也得到一個錯誤。謝謝