php - 为什么 Onesignal 通知不会导致应用程序打开?
问题描述
我正在使用我的网络应用程序通过 API 在 onesignal 中创建通知。
它工作正常并且正在接收通知,但是当用户单击推送通知时,它不会打开应用程序,只是转到手机主屏幕。
任何人都可以在我的代码中看到错误吗?全部在 PHP 中。
<?PHP
function sendMessage(){
$content = array(
"en" => 'testing push message to all active users'
);
$fields = array(
'app_id' => "my app id ",
'included_segments' => array('Active Users'),
'data' => array("foo" => "bar"),
'contents' => $content
);
$fields = json_encode($fields);
print("\nJSON sent:\n");
print($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: Basic my rest APIkey'));
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);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = sendMessage();
$return["allresponses"] = $response;
$return = json_encode( $return);
print("\n\nJSON received:\n");
print($return);
print("\n"); ?>
解决方案
推荐阅读
- google-app-engine - 在 Google Apps Script 中的 Web App 的基本 URL 之后使用 path/slug
- python - 如何在 Python 中的 firebase 事务方法中传递附加参数
- r - 通过预先选择的数据子集在R中循环
- wso2 - 通过 WSO2 EI 6.6 版将多部分表单数据发送到 Rest API
- php - Laravel 中的返回类型提示。好主意还是坏主意?
- android - 如何使用本机反应将时间戳值转换为特定时间格式?
- r - 一张图片中的小提琴情节
- javascript - 尽管返回值,AWS Lambda 仍会重试
- java - 在java中读取写入Excel文件
- r - 如何优化(最大化)R中的函数