Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Easier way to retrieve user device_key for integrations #295

Closed
JRebertt opened this issue Mar 24, 2025 · 3 comments
Closed

Comments

@JRebertt
Copy link

Hi there! 👋
I'm working on integrating Bark into my own backend system to send push notifications to users.

I was wondering: is there currently an easy way to programmatically retrieve the user's device_key (the one used to receive notifications), similar to a “plug-and-play” integration?

Ideally, I’d like to let the user connect Bark to their account without needing much interaction inside the mobile app — for example, using a webhook or a callback after tapping a notification.

Does anything like this exist or is planned? Or would you recommend any best practices for this kind of user onboarding flow?

Thanks in advance for your awesome work on Bark! 🚀

@Finb
Copy link
Owner

Finb commented Mar 25, 2025

Hi there,

You can add your service to the user’s app using a URL Scheme.
Two routes need to be implemented:

/register?deviceToken=&key=

deviceToken: APNs-generated push notification token (may change periodically).
key: Server-generated unique identifier for the user's device.
When the deviceToken is changed, the app will send the key back to ensure the server correctly updates the deviceToken associated with the key.

For implementation details, refer to: https://github.com/Finb/bark-server/blob/master/route_register.go  
/ping  
This simply indicates that the server is running properly and should return `{"code":200}`.  

(You can also simply forward the requests to the Bark-Server.)

URL Scheme:

bark://addServer?address=https%3A%2F%2Fapi.day.app

or

bark://addServer?address=https%3A%2F%2Fyour_host/subpath

Once the user clicks the link and successfully adds the server, your server will receive a register request.

@JRebertt
Copy link
Author

Hey! @Finb 👋

I'm running the Bark server on my VPS using Docker, and I'm trying to better understand how the /register route works.

After the user clicks bark://addServer?address=..., how can I associate the device_key with a user in my system? I’d like to store this key in my database to send notifications to that user later.

Is there any way for my backend to receive this information (like the device_key) automatically when the registration is done?

If there's a recommended approach, could you show an example of how to handle this in Node.js?

Thanks! 🔥

@Finb
Copy link
Owner

Finb commented Mar 26, 2025

An untested but potentially feasible solution:

/:user_id/register?deviceToken=...
/:user_id/ping

Then, provide users with the URL Scheme:

bark://addServer?address=https://your_host/user_id

@Finb Finb closed this as completed Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants