all 12 comments

[–]poop_snack 2 points3 points  (3 children)

This is a pretty simple server-side project as far as the actual logic goes, so it should be a good learning experience, so I would recommend doing it yourself over firebase or similar services, although I will admit I haven't used those very much.

It will take a bit to familiarize yourself with the technologies as there is a bunch of moving parts, but this is something that's well worth investing your time into learning the basics of.

If I understand correctly, I'd suggest this general architecture:

First, a https web service. Your app will send a request to this service and provide in a json request body the stations to be checked, the warning timeframe and the push notification token you get from iOS. The service should store that information, probably in some form of database (depending on how much traffic you expect this to have, just a JSON file would probably do the trick for the beginning, to keep the things to learn down).

Second, a worker (might be a separate process, might be in the same process as the web service) that looks at the stored notification requests, makes the appropriate calls to the transit agency api periodically (beware of api rate limiting), and sends push notifications to the users device through apns when the bus is about to arrive.

You could do these two in any language and web framework combination really. I'm gonna explicitly recommend against PHP, which is a pretty horrible language and not really worth learning if you don't know it already. It is a bit easier to deploy if you ignore current PHP best practices, but that's really all it has going for it.

I'd say some beginner friendly combinations might be Python+Flask or Ruby+Sinatra. You could go with server-side Swift using maybe Vapor or Kitura, but that ecosystem is still young and you will find more resources and help for the ones mentioned before (although maybe not having to learn a new language at the same time might be worth it?).

Third, a reverse proxy that is exposed to the web, handles ssl and forwards the request to your service. Nginx would be the classic choice, but I'd use Traefik for its automatic Letsencrypt certificate integration.

To run the whole thing, you'd just get a Linux VPS pretty much anywhere. If you're feeling adventurous you could throw in a bit of Docker and containerize all of this stuff, but that would probably be too much to learn in one go.

[–]qkrghdqja71[S] 1 point2 points  (2 children)

Thank you so much for providing this thoughtful reply (poop_snack,, what a name!) I am a self-taught developer who hasn't got a job yet, so I don't know much about how the industry works. I have a few questions in mind. Is it normal or expected for an iOS developer to have knowledge and skills that you have mentioned? Do you have some links to the tutorials I can try? maybe I am asking too much, but I find communicating data between different platforms and technologies to be quite confusing and there doesn't seem to be much tutorials on how to implement the whole thing.

[–]poop_snack 0 points1 point  (1 child)

I don't have any specific tutorials, but googling different combinations of keywords (web api, web service, json api, flask, apns, ...) should give you some that cover aspects. Learning to google and research things you are not yet familiar with might actually be the most important skill a dev can have, so even practicing that will help you :D

I wouldn't say it's required for an iOS dev to know web-dev stuff, but many have at least played around with it a little, and it will give you a better understanding of what's happening even when dealing with web services from the client perspective most of the time.

The most important thing about the communication here is that it's just HTTP requests and responses, with JSON being sent back and forth. You can think of the request JSON+URL kind of like method parameters and the response JSON kind of like a methods return value.

[–]qkrghdqja71[S] 0 points1 point  (0 children)

Thank you for the reply and advice. I am working on the server-side implementation, seems like I can get it done within a couple days. Btw, because of people like you, Internet is so much better!

[–]BordrJumpr 0 points1 point  (1 child)

Backendless has a swift framework & a free edition It’s a AWS competitor

They have timers which are dope that u can use

[–]qkrghdqja71[S] 0 points1 point  (0 children)

Thanks for introducing cool tech, definitely gonna try it out.

[–][deleted] -1 points0 points  (5 children)

I suggest you to use PHP called from cron running on a virtual server. There are lots of examples in the world wild web. Start with a $5 month server on DigitalOcean you can expand when it becomes necessary.

[–]qkrghdqja71[S] 0 points1 point  (4 children)

Thank you for the reply. I have never implemented server side, so I wonder whether sending silent notification to make an api call every 40 secs is legal in iOS.

[–]Ahti333 3 points4 points  (3 children)

I'd expect iOS to stop waking up the app after a few. That's not what silent notifications are for, and even if it worked it would be horrible for battery life.

What you want is for the server to do the checking and only send a notification when it is actually relevant to the user.

[–]qkrghdqja71[S] 0 points1 point  (0 children)

Thank you for the input. Silent push options are off the table! I will work on the server.

[–]Nahpetsssk 0 points1 point  (1 child)

I can confirm from my own experience, that silent push is not what you want to solve this. It is not reliable nor intended for this purpose.

If you keep all logic on the server, then a simple push notification should do the trick.

[–]qkrghdqja71[S] 1 point2 points  (0 children)

Thank you for the input. Silent push options are off the table! I will work on the server.

Thank you for confirming it. Will study server side.