Basic-Car-Maintenance
Basic-Car-Maintenance copied to clipboard
FEATURE - Make an App Intent for Adding an Odometer Reading with Shortcuts
Describe the feature you want the app to have that it currently doesn't
- Use App Intents to create a shortcut to add a new
OdometerReading
Describe alternatives you've considered
- N/A
Additional context
- Here's one of the App Intent WWDC videos to help get started
- This is part of a bigger idea with automatic odometer readings, see this discussion, but don't do this whole feature, with the automatic logging, this issue is only for making a shortcut with App Intents
- I haven't used this yet, but if any entitlement things or targets need to be added, let me know and I can add that, and then you can continue on this (rather than you adding anything), because of signing issues and merge conflicts that can happen
@OmarHegazy93 you said you wanted to work on this, please comment below and I can assign it to you!
Hi Mikaela, yes please assign it to me. Thanks!
@mikaelacaron So far I gathered the basic idea to do that, but based on the resources you mentioned and some other investigations, I've some concerns I want to share with you to have the big picture. The way I see it is about two approaches
If the shortcut is intended to be used without opening the app
Concerns
- Currently, to add a new Odometer reading, we have a dependency for the Vehicles as we need to expose the list of the vehicles to the user to select the desirable one
- The only way to have those vehicles right now is by fetching them from Firestore
Possible solutions
- To persist the vehicles locally before sending them to Firestore, and we'll need to keep both of them in sync to make sure that what we have is what already exists in Firestore.
- ⚠️ The Apple tutorials I've seen so far are relying on singletons to access their data (like database and navigation), so that might require a change for the app architecture
- ⚠️ If that works, not sure yet if we will be able to upload the reading through the shortcut or not due to authentication, but it think this can be addressed later
If the shortcut requires the app to be opened
- Most likely it will be strait forward, because we already have the shared instance from the
ActionService
which we can rely on to open the view in the app
That's what's in my mind, please let me know which one you're planning to go for, or of course if you have any questions.
If the shortcut is intended to be used without opening the app
This is not the intention. That isn't possible because there would be no way to enter the number of miles / km for the odometer reading, as of how the app is built right now
You should be able to run the shortcut (in the shortcut we could select which vehicle to use) and then you'd be able to enter an odometer reading, and that would save to Firebase
Is what I'm imaging, I haven't created shortcuts so I'm not 100% sure that is the best way for it to work, but that's what I'd like. A simple way to add an odometer reading, from a shortcut
This is not the intention. That isn't possible because there would be no way to enter the number of miles / km for the odometer reading, as of how the app is built right now
Not sure also, but I think it's doable using the @Parameter
property wrapper to get it as an input from the user.
You should be able to run the shortcut (in the shortcut we could select which vehicle to use) and then you'd be able to enter an odometer reading, and that would save to Firebase
I still can't imagine how we can select a vehicle while we don't have a direct access to them to be listed in the shortcut, unless you're planning to use the ViewModel itself but this will add another complexity as we will need to save user's login information. Do I understand your point correctly?
I still can't imagine how we can select a vehicle while we don't have a direct access to them to be listed in the shortcut
So, first thing, it's not possible to fetch any data from any network inside a shortcut, or (what I imagine with this app) set the shortcut up with any information that comes from a network?
It has to use information that's local??