Devlog: January 18, 2023

I don’t know what got into me. Basically, I nerd sniped myself. I thought, sure would be nice if I could get a notification if it looks like it’s going to freeze tonight.” A somewhat reasonable thought. I could’ve looked for an existing solution, or cobbled together a Shortcut, or use some other use some other automation tool. But no. I had the bright idea to make my own solution and I mostly regret it.

My brain came up with this idea yesterday:

  1. I want a push notification on my phone. (Never done)
  2. Use Apple WeatherKit. (Never used)
  3. Make a server to check the weather and send a push notification to…
  4. Oh yes. Need an iOS app too.
  5. Writing a server? Why not use Go? (Minimal Go experience)
  6. Okay.
  7. What? Why?

All of this made sense in the moment. Using WeatherKit seems like a cool idea. I’ve wanted to give that a try and it has a REST API. Go for the server?? I’ve hardly used Go! I should’ve used Vapor. Better yet, scrap all this and use IFTTT or something. But I was already too far gone. My brain was obsessed and I stayed up to about 2am working on it. It was kinda fun.

The result is a small Go server that should hopefully check the weather at 7pm and send me a push notification if the temperature looks like it will be close to freezing.

The iOS app is literally the SwiftUI starter that requests notification permission when it launches. I archived it and picked ad-hoc distribution and installed it though the device manager in Xcode. Never done that before either. That’s kinda cool.

One little tidbit was how to get the correct string representation of the device token. It’s given to you as Data but it needs to be the hex values. I tried .base64EncodedString() but that did not work. Some googling found this: { String(format: "%02.2hhx", $0) }.joined()

It works.

Anyway. I’m tired. I worked on this too much, and my head hurts. But it was fun. Want a couple more details?


January 18, 2023