Is it possible to implement browser notifications with Laravel API running on one subdomain and the VUE client app on another subdomain - push-notification

I am implementing a VUE client app running on subdomain client.example.com and Laravel API on api.example.com. I am using webpush package to implement the browser notifications. I have my service worker (sw.js) on my vue app and manages to register the user, store the data to database on the push_notifications table.
The problem comes when I simulate the notification, it is not sent to the browser. I tend to think may be it is because the client app that requested for the permission is different from the API subdomain that triggers the notification.
Is there any way to implement this or my worries not realistic?

Related

Strange response on calling Mesibo APIs

I am using Mesibo SDKs on my Android app for chat and so far all my requirements are fulfilled. All of my Mesibo APIs and token information are stored on server side only. The android app fetches user token from the backend server.
Recently, my app started working unexpectedly such as chat messages not sent/received, user account not created and add group not working at Mesibo side. The backend APIs are all working fine. Upon calling one of the Mesibo API from PostMan, I got this response.
Request:
{'token':$appToken,
'op':'groupadd',
'name':$roomName,
'flag':0,
'expiry':$expiry,
'expiryext'"$expiry,
'active':1
}
Response:
{"op":"groupadd","result":false,"error":"TOKENBREACH"}
This error is new to me and I do not know how to resolve this. Any help would be highly appreciated.
TOKENBREACH indicates that backend API and app token are used from multiple IP addresses which jeopardizes your app security. You are likely to be using an app token from the client-side and hence breach has been flagged.
Read here https://mesibo.com/documentation/api/backend-api/

React Native Notification Websockets v/s Firestore listener v/s SSE

I am developing a mobile app using react native. My backend application is developed using springboot. My app talks to backend using REST.
I want to send some notification to the user of the app from my backend (via one of the options mentioned below). This cannot be a Push Notification as user can disable push notification for my app.
On recieveing this notification the app will communicate with backend using rest api's to fetch more details and complete the transaction.
I want to know what would be a better strategy to send a notification for the user.
Websockets
Using Firestore event listener(since I am already using Firebase to send Push Notitification for users who have enabled it)
SSE(server sent events)
Periodic polling from the app to backend (I do not like this approach)
I know this is a bit broad topic. I just need some pointers as to which option is better in terms of fault tolerance, performance and scalability.
I want to know how this is generally implemented. I am new to app development.
In my opinion Firebase is the best option for mobile apps, websocket can be be closed by android and are not always controllable. They also consume a lot of energy which can drain phone battery.
I have the same requirements for a project where need to send notification regardless of using a third party application like Firebase. How I achieve this I will share with you may be it will help you.
Backend -> ASP.NET Core
Real time communication -> SignalR Core
Protocols -> Websocket, Server sent events, Long Pooling
RN Package -> react-native-push-notification
It was completely fine except for one drawback that it will only communicate and send push notification when app is running (background/foreground) I think it depend on your situation and your requirement if your app is continuously will in the main app this will work for you otherwise you need to use the third-party service like Firebase and it will also work when your app is not running just need to be connected with the internet.

Is Firebase Cloud Messaging indicated for social activity messages

I need to handle social activity events in my web app application developed using Vue JS framework and Firebase.
I want to show to the user “Facebook like” notifications when some activity happen in the application, for example:
“John liked your post”.
Is Firebase Cloud Messaging useful for this scenario? Or do I have to develop some custom solution from scratch?
If Firebase Cloud Messaging do the job, is it possible to send messages directly from user web client?
You should not try to send messages directly from the web client. FCM is intended to be used via a secure backend where your code runs to send messages. The reason a backend is needed is to prevent your private server key from being exposed to the world, which can cause security issues in your app.
You will have to arrange on your backend to determine when events occur that should generate messages, and use the Firebase Admin SDK to send those message, or work with the REST API directly.

Firebase authentication with SSR apollo react app

I have a SSR react app that uses apollo. My app server lives under one domain using express while the graphql server is under another domain. I'm having issues trying to understand how the authentication should work.
Currently on my app server I create a cookie session via firebase's documentation. All is fine with that, but I have a couple questions.
I'm currently using firebase's admin SDK to authenticate the request both on the app server and graphql server. I'm doing this because the initial SSR page gets rendered on the server, while all subsequent requests go directly do the graphql server. The redundancy of the authentication doesn't seem to be the right way to do this. Can someone verify?
If this isnt' the right way to do things, should I set up a simple proxy for all graphql requests from my. Essentially making all graphql request going from the client to my app server, which then goes to the graphql server under the hood?
Any other recommendations how to properly set this up? I'm at a complete loss here

Read Notification via web

I want to implement a push notification service. The idea is to use the GCM Service. Is it possible to read the notifications both via web app (the app is written in php using laravel) and via mobile app for the authenticated users using the same technology?
I think it is possible, I also see this tutorial that can help you to achieve that. It also use PHP as a sample, so it seems like your work will be easier:)
It explains here the basic steps that you need to achieve push notification. It has a sample code and a screenshot to make you understand more the content of this tutorial.
In developing this application, it involves two parts, a GCM Server Application that create Web application using Php to send message to User via GCM Cloud server and GCM Client Application that create Android application which receive messages sent from GCM Server Web App.
For more information you can also check this links:
Implementing Push Messaging for Chrome
How to send push notification to web browser?

Resources