Giter Site home page Giter Site logo

mackuba / smogwatch Goto Github PK

View Code? Open in Web Editor NEW
34.0 7.0 3.0 132 KB

watchOS app for checking air pollution levels, created for my blog post series

Home Page: https://mackuba.eu/2018/10/29/watchkit-adventure-0-intro/

License: Do What The F*ck You Want To Public License

Swift 96.54% Ruby 3.46%
watchos watchkit apple-watch smog air-quality air-pollution krakow poland

smogwatch's Introduction

SmogWatch

This is an app I'm building for my blog post series "WatchKit Adventure". Its goal is to display the level of PM10 smog pollution (fetched from a local monitoring station) on the Apple Watch's watch face. Initially it only works for a single preset station in Kraków, Poland.

The second goal is for me to learn programming for watchOS and also get some experience that I can share in the blog posts :)

Installation & Running

If you want to try out the app, clone the repo (or download a zip) and open it in Xcode. There are currently no external dependencies, so just build the project.

Running a watch app in the simulator is about 100x easier than getting an actual device to cooperate, so try that first. Then, to run on the real watch, you will probably need to edit at least the developer team and the app ID. If you manage to run it, let me know what else you needed to do :)

The app currently uses http://monitoring.krakow.pios.gov.pl for the data and has a hardcoded ID of PM10 parameter on the Kurdwanów station. If you want a different station (as long as it's from the Małopolska monitoring system) then open the site in the browser, select only PM10 parameter only on one selected station, load the data and check in the web inspector what parameter was sent in the request. The query in KrakowPiosDataLoader.swift is the place you need to update.

Yup, it's all very very rough right now - did I ever say this was a finished app? It's basically version 0.0.1 :)

It's possible that there are other regional monitoring systems in Poland that use the same API, so let me know if you find one.

Complications

The part that's working so far is complications. Not all families are supported, currently Modular Small works best since that's what I primarily use (on Modular or Siri watch faces). If you really want to use a different complication that isn't supported yet, look in ComplicationHandler.swift, and also enable the complication family in the target settings.

Main UI

The app itself has currently no UI whatsoever, so if you see a black screen, don't worry, it's not broken. First things first, you know...

Credits

Copyright © 2019 Kuba Suder. Licensed under WTFPL License.

I've made the code available under WTFPL because the whole idea is for other people to be able to learn this stuff together with me and reuse any pieces they need from my app to build their own. So take what you need and build cool shit, and don't worry about licences. Of course if you want to mention me somewhere, I'll be very happy :)

smogwatch's People

Contributors

mackuba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ktoso agcii macf2021

smogwatch's Issues

can't show PM10 data on Apple Watch

image
image
image

I try with same parameters on Postman, which works. and then I hardcode those params for Apple watch extensions as show above, but failed to fetch data on apple watch.

Tried your app, works on simulator but no background refresh on device

Hi!
Thanks for sharing your code. I've run into it because I'm trying to do something similar (getting data from a website to display on the watch and a complication, without an iPhone app running).
I've installed and ran your app, it works 100% on the simulator, but on my device (watch 4 44mm running 5.1.3) the background refresh is scheduled but never happens.
Have you managed to run your app on a device?

How can you use URLSession in a background refresh task

I am writing a weather application which should provide some complications and after watching the WWDC video the slide at 20:51 states that you cannot use URLSession in a Background App Refresh task. If I understand your code, this is exactly what you do though and I would like to know if you had any problems with this?

AFAIK, the documented way to do this is schedule a url session background task to download the json, then decode it and store it (in your case in user defaults) and in the extension delegate's handle(:) schedule the next background task and reload the complications.

OpenSense Sensor data

Hi, I'm trying to build my first Apple Watch app based on your project. I want to eventually add more features, so that user can choose the base station (or better yet data is served from closest one). I would like to use sensors from opensensemap. They have a simple API which I can query successfully from Postman, but I don't have experience getting data with swift.

I can't read these two values: lastMeasurement.value and lastMeasurement.createdAt

Could you please give tips on how to modify the KrakowPiosDataLoader.swift so that it would work with a basic JSON? Thank you.

Screenshot 2019-05-24 at 11 29 42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.