Closed pwFoo closed 5 years ago
I would say it's a couple of months away.
@or-else Thanks for your quick reply! Do you plan to implement a fix solution like FCM or by browser / device decision (Chrome, Firefox, Edge)?
Push notifications would be awesome :)
FCM is already implemented in the server for mobile pushes, so it's going to be FCM-based for browsers too. https://github.com/tinode/chat/blob/master/server/push/fcm/push_fcm.go
BTW, you are welcome to help out with a pull request :)
I'm new with git pull requests and programming (golang, web notifications api, ...). So I don't know if I really can help here, but I'll take a look.
Tried a little bit with php / javascript based on that example which uses browser / vendor dependent push service.
e.g. Firebase Cloud Messaging (FCM), Mozilla Cloud Services (MCS), and Windows Push Notification Service (WNS) depending on which browser is being used
I would prefer to let the device choose the push service itself (Edge -> WNS, Chrome / Android -> FCM, FIrefox -> MCS).
FCM supports all browsers with support for Web Notifications API https://firebase.googleblog.com/2018/05/web-notifications-api-support-now.html
Which means everything but Safari is supported: https://caniuse.com/#feat=push-api
Ok, but FCM is related to google, right? So maybe some users use Edge / Firefox / Opera instead of Chrome to avoid Google? Chrome and Android is related to Google / Gmail and FCM would be fine.
Client side could be done with Javascript (un-/subscribe) and send subscription to the Server.
Server use the client subscription with preferred service.
How complexe is server side? Pub / priv key and call the subacriber service for example with curl? Service url is given by client service subscription.
It's a matter of practicality. FCM is done. Non-FCM pushes are not done. I personally have no time for it. If someone wants to implement them - great, I'll support the effort.
Any update on this?
I built cross browser notifications based on the demo. Reduzed to the needed code. But it needs some rewrite / code clean up first.
And I don't know how to implement to the react client. Any plans to separate html / templates and js to different files? Should be easier to read, modify or maintain.
I built cross browser notifications based on the demo
Great.
Any plans to separate html / templates and js to different files?
React components are expected to include html (jsx) and js in the same file.
Maybe I take a look into the tinode.js lib how to build a custom client, but at the moment I have no time to play with or rewrite the notification code. I think I need some weeks to do other tasks first...
After some rewrite I could send you the client side notification code to take a look?
After some rewrite I could send you the client side notification code to take a look?
Absolutely. Would be glad to see it.
I'll close this issue. Once you get to working on it, please open a new one or write to https://groups.google.com/d/forum/tinode
@or-else https://groups.google.com/forum/#!topic/tinode/k8LzEApbwTM With link to a demo / repo
@or-else Do I need a FCM account for push notifications?
Yes, you need an FCM account.
With webpush-go library there is no account needed, but at the moment I haven't time to rewrite / cleanup the client side javascript code...
Do you know an easy howto? I need to create a FCM account to add push to my tinode test system.
Go to https://console.firebase.google.com/ Create an account, create your project, configure it, start pushing. The FCM push is free.
Account and project created.
projekt id added to docker run, but FCM_CRED_FILE
?
Go to Service Accounts. It's there
And you need to enable messaging api at console.cloud.google.com
Ok. Activated messaging and found a snippet (node.js, java, python, go) on "Firebase Admin SDK" page, but no json file / path / url / content.
It looks like I have to add a file to the container web path?
Keep in mind that it exists, it works. Yes, it is complex. Yes, it is convoluted. But with enough persistence it works.
It looks like I have to add a file to the container web path?
Not sure what you mean by web path, just follow instructions here: https://github.com/tinode/chat/tree/devel/docker#enable-push-notifications
Strange...
Verified file and content is correct mapped inside container. And also checked generated tinode config... cred file isn't read as should?
tinode container runs as root, file in volume exists content is the downloaded json file I can output the json file configured in the tinode config as long as the container runs (docker exec before container stops)
But tinode container stops with (got the logs with a /var/log/ volume to have persistent logs without running container...)
2018/09/22 15:01:23 Server v0.15:/opt/tinode/tinode:v0.15.6-rc5; db: 'mysql'; pid 46; 2 process(es)
2018/09/22 15:01:23 Using config from '/opt/tinode/working.config'
2018/09/22 15:01:23 Running as a standalone server.
2018/09/22 15:01:23 Failed to initialize push notifications:missing credentials
browser dependent push service just work with a priv / pub key generated server side. No account needed. So if tinode switches in the future it would be easier to use push notifications.
Each time I get
2018/09/22 15:15:23 Failed to initialize push notifications:missing credentials
But don't know how to debug it.
It's a locale problem because there is no traffic to FCM outgoing. So why the creds not found if path / file in config is fine and the cred file exists?
It's my bug. The docker template has credential_file
while the code expects credentials_file
.
ok, could I fix it somewhere or by an additional env variable? Or should I wait for the next docker dev image?
I'll release a new docker with the fix tomorrow.
0.15.6 released.
Looks like there is still a problem? I'm able to start the tinode app after I changed to the latest image. Tested with Chrome, Chrome Incognito and a mobile. No push notifications.
2018/09/23 15:57:30 fcm push failed http error status: 403; reason: sender id does not match regisration token; code: mismatched-credential; details: The caller does not have permission
Yep. I forgot about hardcoded key and sender ID in the javascript files too: https://github.com/tinode/webapp/blob/master/src/webapp.jsx#L38 https://github.com/tinode/webapp/blob/master/service-worker.js#L7
Now I need to figure out how to pass them to the webapp in the container.
But the error you are getting means that the server is set up correctly.
Yes, it looks good, just the right credentials are missing.
0.15.7-rc1 takes two new credentials for the client-side.
My I have still problems after update.
I can't de-/activate the Notification alert checkbox by click / keyboard.
Same with mobile (can't check the checkbox). Desktop and mobile same problem after clear cache / temp data / cookie / ... and incognito browser too.
Developer tools console:
Failed to initialize push notifications {code: "messaging/bad-sender-id", message: "Messaging: Please ensure that 'messagingSenderId' …ebase.initializeApp(). (messaging/bad-sender-id).", stack: "FirebaseError: Messaging: Please ensure that 'mess…s://<DOMAIN>/umd/index.prod.js:1:70982)"}
Are you using correct sender ID?
If you connect to a running container
docker exec -it name-of-the-running-container /bin/bash
what's the content of /firebase-init.js?
cat /firebase-init.js
The content of /firebase-init.js is public, you can freely post it here.
Or, actually, see the contents of firebase-init.js in the browser: http://localhost:6060/firebase-init.js
File doesn't exist
/opt/tinode # cat /firebase-init.js
cat: can't open '/firebase-init.js': No such file or directory
Web file exists, but empty...
const FIREBASE_INIT={messagingSenderId: "", messagingVapidKey: ""};
I think something is wrong with my docker command... Let me check...
did you provide the values on the command line when launching the container?
--env FCM_SENDER_ID=... --env FCM_VAPID_KEY=...
it's actually cat /static/firebase-init.js
Problem are the missing env variables... But where I get sender_id (fcm project_id?) and vapid key?
Looks like I fixed it. Found the needed values in firebase console and try to test it
FCM is... annoying
2018/09/25 18:30:23 fcm push failed http error status: 403; reason: sender id does not match regisration token; code: mismatched-credential; details: The caller does not have permission
This error means your client-side credentials do not match your server-side credentials.
You can try sending a push from the firebase console to the client side token. This way you can be sure that the client side is set up correctly.
Where can I send a test push?
It would be so easy with browser dependent push instead of FCM. I hope it'll switch in the (near) future. I think I'll test it tomorrow if I have some time... Frustrating to set it up :(
"Browser push notifications are not implemented."
Is it planned in the near future? Would be great for desktop browser and closed browser notifications with mobile / android.