Unable to make android notifications appear as a banner
sanaddfffrnt opened this issue · 0 comments
sanaddfffrnt commented
Hello,
I'm working on displaying Android notifications as banners/bubbles instead of just in the notification drawer. I attempted to set the android_channel_id in our REST API to the OneSignal dashboard's Channel Id value, but it caused issues with notifications appearing in the drawer.
Could someone please provide a clear example of how to configure this in the REST API? The documentation isn't providing enough clarity.
Here is the sendPushNotification
const axios = require('axios');
const sendPushNotification = async (messages) => {
for (let i = 0; i < messages.length; i++) {
const message = messages[i];
const options = {
method: 'POST',
url: 'https://onesignal.com/api/v1/notifications',
headers: {
accept: 'application/json',
Authorization: 'Basic ' + process.env.ONESIGNAL_API,
'content-type': 'application/json',
},
data: {
app_id: '1234',
android_channel_id: '1234',
include_external_user_ids: [message.to],
contents: {
en: message.body,
},
headings: {
en: message.title,
},
},
};
await axios.request(options);
}
try {
} catch (error) {
console.error('Error sending push notification:', error);
}
};
module.exports = { sendPushNotification };