Hi,
I'm looking for the best way i can include the following HTML code to the Header tags for Web App.
It's the coed for Web push notifications from OneSignal.com
<head> <link rel="manifest" href="/manifest.json"> <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script> <script> var OneSignal = window.OneSignal || []; OneSignal.push(["init", { appId: "YOUR_APP_ID", autoRegister: false, notifyButton: { enable: true /* Set to false to hide */ } }]); </script> </head>
Hi Bil Mizan, I'm not sure if it's possible.
Why don't you use Jquery.ready? Try to put code javascript on body of HTML and using the Jquery.ready.
$( document ).ready(function() { your code; });
$( document ).ready(function() {
});
Paulo Ricardo Fagundes Junior wrote:
Hi paolo, Could you help me step by step how to add it as am totally new to JS
Well, it is possible:
$('head').append('<script>...');
But it's mor like an work around. I like @Paulo's solution more... ;)
Adding javascript is always possible, but I would vote for an OutSystems way of adding the link and script tags.
Add the dependencies for "AddJavaScriptTag" and "AddLinkTag" from them HTTPRequestHandler extension.
Where would I put the AddJavaScriptTag function in order to include it on a page? I've tried in the OnInitialize function, but it doesn't work there.
Thanks,
Bil Mizan wrote:
Hi, there is a plugin for OneSignal already on Forge.
And I also have customized it, so you can send notification to specific user easily.
You can also tag user with specific key-value pair, example: segment=areamanager, then send notification to that specific tag.
I attached my customized OneSignal Plugin on this post, so maybe you can jumpstart using it already...
Steps:
1. Put OneSignal block on your Common\Layout (directly under root element)
2. Call RegisterDevice in your On-Logon (after DoLogin/UserLogin)
3. Use PostNotificationToUser action to send push notification
EDIT: Ooops sorry, I didn't read the Web Push part... Maybe it uses same API?
Hello guys,
I have a similar problem, i need to add a specific script on <head>,
<script type="text/javascript"> dataLayer = [{ 'TyperUser': '" + UserType + "', 'Screen': '" + PageName + "' }];</script>
but, without src=.
How i need get the page name, i'm trying doing at OnBeginWebRequest, to create a script in my all pages.
I need the result in the html <head> to be the same as:
if someone could help me, i would be very grateful.
Tnks.
Agno Silveira wrote:
Solution, for this case:
https://www.outsystems.com/forums/discussion/60447/add-script-in-all-pages-without-src/
could be helpful,