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

How to upload .fit file to Strava ?? #12

Open
jvashisht opened this issue Jan 12, 2018 · 9 comments
Open

How to upload .fit file to Strava ?? #12

jvashisht opened this issue Jan 12, 2018 · 9 comments

Comments

@jvashisht
Copy link

No description provided.

@frogg
Copy link

frogg commented Nov 17, 2018

I am also running into quite some issues when I attempt to upload a new activity to Strava.

For now I don't even want to include a file, I just want to create a new activity (e.g. running 5km). So far, I always get a 400 (Bad Request) response from Strava.

@AnshulIronNetwork
Copy link

@frogg Are you able to create a new activity? If yes, can you please share your code. As I am also trying to create a new activity but got errors.

@frogg
Copy link

frogg commented Dec 28, 2018

I didn't check about the .fit file itself yet but I am able to contribute basic session info to starve. Example:
https://www.strava.com/activities/1999653605

Ended up using this lib instead:
https://github.com/SweetzpotAS/StravaZpot-Swift

See my PR here how to update it:
SweetzpotAS/StravaZpot-Swift#5

@AnshulIronNetwork
Copy link

Thanks for your reply. I have created an activity using alamofire by hitting the url and passing the parameters.

Can you please help me in the authorization callback domain because strava don't let anyone add the custom url like myapp:// (This field must be a domain, no slashes or path). But the safari needs an url scheme with colon, slashes to open the app on return from the authorization.

When I have checked the code of this example, I come to know that the given redirect uri also contains ://. So how can I register my application redirect uri ?

@mjunkmyjunk
Copy link

@AnshulIronNetwork I can't help on the upload but https://stackoverflow.com/a/65092728/14414215 this is how I managed to get redirectUri to work.

could you share how you created the activity? I am having trouble on the syntax to call for the upload. (There isn't an example in the readme.md or the example app)

@frogg I checked out StravaZpot but the syntax is a little bit hard for me and there wasn't an example project for me to refer to within it. You mentioned you managed to contribute a basic session. Could you share how you called the Instance?

Thanks

@frogg
Copy link

frogg commented Dec 2, 2020

@frogg I checked out StravaZpot but the syntax is a little bit hard for me and there wasn't an example project for me to refer to within it. You mentioned you managed to contribute a basic session. Could you share how you called the Instance?

Use my fork of StravaZpot instead, the original repo doesn't seem to get any recent updates (indeed it has been archived by the author):
https://github.com/frogg/StravaZpot-Swift

@mjunkmyjunk
Copy link

@frogg Thank for your repo link. I read thru the original repo and truth be told, I'm a bit stumped as to how to integrate it into my project. In fact, I don't even know where to start. (Newbie)

in fact, it says this in bold -> you are responsible for calling this code in a suitable thread, outside the UI thread. and I'm not even sure how to begin.

Would appreciate any help or an example project like what StravaSwift offers.

@frogg
Copy link

frogg commented Dec 2, 2020

@frogg Thank for your repo link. I read thru the original repo and truth be told, I'm a bit stumped as to how to integrate it into my project. In fact, I don't even know where to start. (Newbie)

in fact, it says this in bold -> you are responsible for calling this code in a suitable thread, outside the UI thread. and I'm not even sure how to begin.

Would appreciate any help or an example project like what StravaSwift offers.

I‘d recommend looking into the documentation of dispatch queues:
https://developer.apple.com/documentation/dispatch/dispatchqueue

The use for this is pretty simple:

DispatchQueue.global(qos: .background).async {
// make calls to the Strava API, they are now on a background thread
}

and then to upload a GPX file:

let gpxFileUrl = session.generateGPXFile()
let uploadAPI = UploadAPI(client: client)
let fileUpload = uploadAPI.upload(file : gpxFileUrl,
                                  withFilename : gpxFileUrl.lastPathComponent,
                                  withDataType : .gpx,
                                  withActivityType : .rockClimbing,
                                  withName : "\(ClimbingBusinessLogic.title(forClimbingType: session.climbingType)) Session",
                                  withDescription : "\(session.sessionDescription())\n\nTracked with Redpoint, https://redpoint-app.com",
                                  isPrivate : false,
                                  hasTrainer : false,
                                  isCommute : false,
                                  withExternalID : session.uuid.uuidString)

@mjunkmyjunk
Copy link

@frogg I'll read up on the DispatchQueue. I'm still wrapping my head around the auhenticationController and where to put it. In codes I've seen, looks like simplest would be to put it into appDelegate.swift and create it like a singleton (similar to StravaSwift) and then use the shared instance everywhere else?

Again thanks. I'll bang my head on the wall a few more days and see if I can get anywhere.

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

4 participants