Hi
I want to use the Close Your Ring apple watch app data into my app. Is there any way to save our apple watch data into our database to use it into IOS Apps.
I want to save the data when the ring is completed.
Please recommend any blog or tutorial to use the Apple Watch Close Your Ring app data into our IOS App.
Thanks 😊 :)
Post
Replies
Boosts
Views
Activity
Hi Guys, I am trying to run the function into the OnAppear and the function runs correctly but the View does not change when the ViewModel values change.
ViewModel:
import SwiftUI
class LocationDetailViewModel: ObservableObject {
@Published var amenities: [Amenity]?
@Published var isLoading: Bool? = true
@Published var error: String?
func fetchAmenities(dbLocation: DBLocation){
Amenity.fetchAmenites(dbLocation: dbLocation) { [weak self] (locationAmenities, error) in
self?.isLoading = false
if error == nil{
print("Success!!!!!!!")
if let locationAmenities = locationAmenities, locationAmenities.count 0 {
self?.amenities = locationAmenities.map{ $0.amenity }
}
}else{
print("Error!!!!!!!!!")
self?.error = error?.localizedDescription
}
}
}
}
View:
import SwiftUI
import SDWebImageSwiftUI
import MapKit
struct LocationDetailView: View {
let dbLocation: DBLocation
@State private var isPresentingSaveToCollection: Bool?
@State private var isPresentingToast: Bool?
@State private var toastText: String?
@ObservedObject var locationDetailViewModel = LocationDetailViewModel()
let defaultImageUrl: String
var body: some View {
GeometryReader{ geometry in
VStack{
if locationDetailViewModel.isLoading ?? true {
VStack(alignment: .center){
InProgressView()
}.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height, alignment: .center)
}else{
LocationView(dbLocation: dbLocation, defaultImageUrl: defaultImageUrl, isPresentingSaveToCollection: $isPresentingSaveToCollection)
.environmentObject(locationDetailViewModel)
.padding(.top, geometry.safeAreaInsets.top)
.background(SwiftUI.Color( colorLiteral(red: 0.9644473195, green: 0.9684088826, blue: 0.9848803878, alpha: 1)))
.edgesIgnoringSafeArea([.top, .horizontal])
}
}
}
.onAppear{
locationDetailViewModel.fetchAmenities(dbLocation: dbLocation)
}
.navigationBarHidden(true)
.fullscreenModal(isShowing: $isPresentingSaveToCollection) {
SaveToCollectionView(isPresentingSaveToCollection: $isPresentingSaveToCollection, isPresentingToast: $isPresentingToast, toastText: $toastText)
}.toast(isShowing: $isPresentingToast, message: toastText ?? "Undefinded Toast")
}
}
struct Theme: Codable{
		 	 var color: Color
				var cards:[MemoryGame<CardContent>.Card]
				var name:String
		}
Here the var color: Color is not going to be Codable. So whats the solution.