I would like to add a notification banner as an addition to an existing github application. This banner would displays a warning whenever the temperature rises above 90°F or 32°C and drops below 50°F or 10°C. I am using Swift 4 and xcode 9.4 and am new app development.
I have taken a look at this guide and to these instructions to build a simple weather application, but they do not describe how to add a notification with the temperature. Is there a way to access the weather information or about the temperature from the app.
I have read about using UNUserNotificationCenterDelegate from this post and want to find a way to simple display a temperature warning. I would appreciate any code snippets that can illustrate how to accomplish this.
There is a couple of steps you need to do before even thinking of sending a notification. But let's clear in the beginning this:
There is no code snippet for this, because it's not as trivial as it may sound. I will provide you a list of steps below and you can google tutorials for it or use links I will provide:
CLLocationManager
with Always
option, you'll need this to check temperature based on user location in background: Here is a useful link how to get permission and delegates right: https://www.techotopia.com/index.php/A_Swift_Example_iOS_8_Location_Application. That will be perfect solution for first implementation of your challenge. Later you may have a look at: Significant Location ChangeCodable
approach: https://medium.com/xcblog/painless-json-parsing-with-swift-codable-2c0beaeb21c1Happy Coding