我正在使用 OneSignal API 通过我的 Flutter 应用发送和接收通知。而且我不知道如何使用可以添加到通知的按钮将我的 flutter 应用程序打开到特定屏幕。
我的 API 用例是创建一个带有按钮的通知模板并将其发送给我的用户。但我不知道如何在那个将打开我的 flutter 应用程序的按钮上设置监听器。
我正在为我的节点服务器使用 onesignal-node 包。
let firstNotification = new OneSignal.Notification({
template_id: "727f42a8-0b45-470e-ac9e-908f64af44ba",
include_external_user_ids: [_id]
});
myClient.sendNotification(firstNotification, function (err, httpResponse, data) {
if (err) {
return res.status(500).send(err);
} else {
console.log(data, httpResponse.statusCode);
return res.status(200).send("Notification sent to " + user);
}
});
最佳答案
这是解决方案
buttons: [
OSActionButton(text: "text button 1", id: "id1"),
OSActionButton(text: "text button 2", id: "id2")
],
但我不知道如何为按钮设置事件 =(
关于flutter - 如何在 Flutter 中使用 OneSignal 通知按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56197764/