Hi Fliplet Community,
I’m an amateur coder… dont judge… trying to work with Fliplet, and I’m experiencing an issue where my screen performs an in-app visible notification update (not a silent or forced update) each time I send a push notification from my screen from a custom code. I made my own notification set up. (I don’t use the dashboard one)
The push notification includes additional elements like navigation and sound, so it may be something within these settings causing the visible refresh.
Here are some specific details:
- Here is my code for PUSH part the screen:
// -------------------- Send Push Notification Function --------------------
function cleanText(text) {
return text
.replace(/<[^>]+>/g, '') // Remove HTML tags
.replace(/ /g, ' ') // Replace non-breaking spaces
.replace(/&/g, '&') // Replace '&' entity
.replace(/’/g, "'") // Replace right single quote
.replace(/‘/g, "'") // Replace left single quote
.replace(/”/g, '"') // Replace right double quote
.replace(/“/g, '"') // Replace left double quote
.replace(/"/g, '"') // Replace generic double quote
.replace(/–/g, '-') // Replace en dash
.replace(/—/g, '-') // Replace em dash
.replace(/</g, '<') // Replace less than symbol
.replace(/>/g, '>'); // Replace greater than symbol
}
const cleanTitle = cleanText(title);
const cleanBody = cleanText(body);
console.log("Cleaned Title:", cleanTitle);
console.log("Cleaned Body:", cleanBody);
const notificationObject = {
type: 'push', // Specify as push notification type only
pushNotification: {
payload: {
title: cleanTitle,
body: cleanBody,
sound: "default",
custom: {
customData: {
action: 'screen', // Define specific action
page: 1028802, // Replace with actual screen ID if needed
transition: 'fade'
}
}
}
},
status: "published" // Set to published to send immediately
};
console.log("Notification Object:", notificationObject);
console.log("Attempting to send push notification...");
try {
Fliplet.Notifications.init({}).insert(notificationObject)
.then(function() {
console.log("Push notification sent successfully");
alert("Your push notification was sent successfully!");
// Reload page to reset form
location.reload();
})
.catch(function(error) {
alert("An error occurred while sending the push notification: " + error);
console.error("Error sending push notification:", error);
});
} catch (error) {
console.error("Error initializing or sending notification:", error);
}
}).catch(function(error) {
alert("An error occurred while submitting: " + error);
console.error("Error sending push notification:", error);
});
}
});
-
Custom Code: There is the custom code… Could you please review it to see if anything within the code could be triggering this in-app visible update unexpectedly?
-
Push Notification Details:
- The push notification includes navigation, sound, and fade settings.
- The update appears to be triggered upon sending the push or during the auto navigation action when I click the push notification that was just recieved.
- Potential Triggers:
- It’s possible that the app is interpreting one of the notification settings (such as sound or navigation) as a content change, prompting a visible update instead of a silent background refresh.
Could anyone help me investigate why this visible update is triggered with each push notification from this screen? Any insights into managing this behavior or adjusting the push notification settings would be greatly appreciated.
Thank you!