我用一个信号sdk在我的应用程序上有推送通知,但是我对如何用一个大图标发送信息有不同的理解,我的意思是当用户收到推送(而不是显示铃铛)时保持左边的图标,...i知道图标必须是透明的,并且有256 one 256 be。我使用rest发送推送,但我不知道问题出在哪里,因为似乎没有什么工作,下面是我的代码:
public function sendMessage($messagePush){
$subtitle=["en" => $messagePush['message']];
$content = array(
"en" => $messagePush['contentJson']['tipoImovel'],
"large_icon" => public_path('img/icon.png')
);
$hashes_array = array();
array_push($hashes_array, array(
"id" => "id1",
"text" => "Ver"
));
$fields = array(
'app_id' => "myappid",
'included_segments' => array(
'All'
),
'data' => array(
"imovel" => $messagePush['contentJson']
),
'headings'=> $subtitle,
'contents' => $content,
'buttons' => $hashes_array
);
$fields = json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Authorization: my autorization'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
curl_close($ch);
return $resp;
}我可以接收推送,但是图标永远不会出现,另外还有一个problem...the推送总是出现在顶部托盘上,而不是弹出的“种类”,因为下面的方式也是我在app.js上的代码:
if (application.android) {
application.on(application.launchEvent, (args) => {
try {
TnsOneSignal.startInit(application.android.context).setNotificationOpenedHandler(new TnsOneSignal.NotificationOpenedHandler({
// notificationOpened: function (result: com.onesignal.OSNotificationOpenResult) {
notificationOpened: function (result) {
const imovelAndroid = JSON.parse(result.stringify()).notification.payload.additionalData;
handleOpenURL(imovelAndroid);
}
})).init();
TnsOneSignal.setInFocusDisplaying(TnsOneSignal.OSInFocusDisplayOption.Notification);
TnsOneSignal.startInit(application.android.context).init();
}
catch (error) {
console.error('error', error);
}
});
}如果我删除TnsOneSignal.setInFocusDisplaying(TnsOneSignal.OSInFocusDisplayOption.Notification);弹出样式出现,但按钮不适合我的handleOpenURL function...but如果我让它停留,它确实导航,但推总是在托盘上。
有小费吗?耽误您时间,实在对不起。问候
发布于 2019-03-13 16:07:32
您必须删除TnsOneSignal.setInFocusDisplaying(TnsOneSignal.OSInFocusDisplayOption.Notification);,因为这将迫使通知成为托盘通知。默认的一个已经是InAppAlert。
第二次呼叫startInit时,您正在重置startInit。因此,如果您也删除了第二个startInit语句,那么您应该是好的。
https://stackoverflow.com/questions/55126608
复制相似问题