Questions on Strava Webhook registration

273 views
Skip to first unread message

Maksim Gazimzyanov

unread,
Apr 22, 2021, 3:12:10 AM4/22/21
to Strava API
Hi!

I'm developing an iOS application that notifies a user when he finishes a ride. I want use webhook subscription instead of polling REST API periodically but cannot get how to do that wisely...
On the official documentation pages it is written to register a new subscription with a callbak url that will be used by Strava to send events to. For me, in case of development setup it is easy to create such url (using ngrok or something) but how should I handle that for production when there are several users with installed application? Should I create its own callback url for each application instance or that is not how it works and I need to have one server instance that listens to all the events and then distributes to ny application instances?
Thanks in advance!

Best regards,
Maksim

Jan Szewczak

unread,
Apr 22, 2021, 11:54:18 AM4/22/21
to Strava API
Hey,

json sent to callback looks like:
{"updates": {}, "owner_id": [owner_id], "object_id": [activity_jd], "event_time": 1619083593, "aspect_type": "create", "object_type": "activity", "subscription_id": [id]}

So you must connect in db owner_id with your user_id and save event for that user_id

for example:

user_id(from your app) = 1234

So you receive json to adres yourdomain.com/callback
and if that json have field owner_id == 12345678 then you can save in column user_id value 1234 then you know that this event was for that user.

*Also when you receive callback set user_id to null then using cron/async event update user_id that receiving callback will be quicker

Maksim Gazimzyanov

unread,
Apr 23, 2021, 1:09:17 AM4/23/21
to Strava API
Hi,

Thanks for you answer!
So as far as I understand, there is no way to make it work with multiple mobile application instances without server application, is that right?

In case of one server application with several mobile application instances, how is it possible to subscribe for updates for different users as basing on Strava docs, it only allows one subscription per user?
четверг, 22 апреля 2021 г. в 18:54:18 UTC+3, jane...@gmail.com:

Jan Szewczak

unread,
Apr 23, 2021, 9:18:13 AM4/23/21
to Strava API
From:

"Subscriptions
Each application may only have one subscription, but that single subscription will allow the application to receive webhook events for all supported changes to data owned by athletes that have authorized that application. Here is an example of how to create a dummy server to create a webhook subscription."

Maksim Gazimzyanov

unread,
Apr 23, 2021, 10:50:40 AM4/23/21
to Strava API
Oh, I must read more carefully...
Appreciate your help!

пятница, 23 апреля 2021 г. в 16:18:13 UTC+3, jane...@gmail.com:
Reply all
Reply to author
Forward
0 new messages