Hi,
I was wondering how to use this forge as I cannot consume mobile's client action in reactive application (obviously) and can we have a demo on how to register the user on RWA?
OR.. does it mean we have to register ourselves on mobile, only then the push notification will be sent to my "web application" after logging into my web application? Thanks!
Kenny
Kenny,
The OneSignal Forge component is initially designed for mobile applications. However, you can definitely adapt it to work with a Reactive Web Application.
Here are some steps you can follow to implement OneSignal API for Web Push Notifications in your RWA:
[ <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script> ]
[ OneSignal.init({ appId: "your-app-id-here", autoRegister: false, }); ]
[ OneSignal.registerForPushNotifications(); ]
[ OneSignal.on('notificationDisplay', function(event) { console.log('OneSignal notification displayed:', event); }); ]
Please note that you don't have to register the user on mobile to receive notifications on the web application. You can directly register your web users for push notifications using the existing structure available.The Web Quickstart documentation on OneSignal's website should fill in the blanks:https://documentation.onesignal.com/docs/web-push-quickstart
Feel free to reach out if you have more questions or need further clarification.
Best regards,RAD Manage
Hi Yung Shin ,
Basically a mobile PWA application is just a web application running on a shell over the the phone browser, so the mobile OneSignal Forge component won't work on PWA applications, just the native mobile ones.
This component will implement the notification with OneSignal on mobile PWA apps. For Web app the code is exactly the same, you just need to copy the logic to a Web app module, as I forgot that a reactive application can't consume a mobile's client action.
To register the user you just have to run the RegisterUser client action anywhere you see fit on your application, depending on the use case. As you do that this component will automatically save the OneSignal PlayerId, that you can use later to send notification to that user phone (or web browser), trough the One Signal API.
This is just the basics but you can check the OneSignal Documentation to customize and add features to your notifications.
Let me know if you need any further clarification.
Best regards,
João Amaral
Hi Joao,
Thanks for your reply. I tried to implement it in my RWA, but I'm receiving the following message.
I've copied the sw.js to my RWA and set the module name as 'SandboxReactive'. The playerId is not captured/stored in the database.
Not sure if I missed anything here..