We’ve arrived at day 84 of the 100 Days of SwiftUI! We’re edging ever closer to the end of this course. Yesterday, we learned about QR codes and how to implement them into our app. Today, we’re going back into UserDefaults and notifications.
Saving and loading data with UserDefaults
As it stands, when using the app, everything works as expected. You could say it’s a minimal viable product. However, there is a large problem which may not seem apparent right away: whenever we close and relaunch our app, all data is wiped out. That’s because we’re not saving it anywhere just yet. To resolve this, we’ll implement saving and loading data from the
Adding a context menu to an image
We’ve already written code that dynamically generates a QR code based on the user’s name and email address, but with a little extra code we can also let the user save that QR code to their images. As always, Paul’s got us covered.
Posting notifications to the lock screen with SwiftUI
The final part of this app is adding yet another option to our list of swipe actions. In this case, we want our users to be able to set a notification for themselves, more specifically, a reminder to contact a specific person. This will use iOS’s UserNotifications framework to create a local notification, and we’ll conditionally include it in the swipe actions as part of our existing
if check – the button will only be shown if the user hasn’t been contacted already. SwiftUI makes this quite easy.
And that’s it for day 84! With another app finished and a lot of advanced features learned, we move ever closer to the end of this journey. Stay tuned though, there are more than two weeks still upcoming.