Post

Replies

Boosts

Views

Activity

Sign in with Apple - problem when account is deleted
I'm currently working on a Swift app whose data storage and authentication part is managed by Firebase. I would like to offer my users the possibility of using their Apple account for account creation. To do this I added Apple as a “Connection Provider” in the Firebase console settings. 
 

 This part works without problem, when the user clicks on the “Sign in with Apple” button a popup appears asking if they agree to share this information (first and last name / email address) for account creation.

 After entering the password, the user is authenticated and their account is created on Firebase.
  If I go to the iPhone settings in the Connection and Security section > Sign in with Apple, I can see my app in the list.
  Now my problem is at the time of deleting the user's account. When the account is deleted it no longer exists in Firebase as we expected.
  An email is also sent by Apple to warn that the application has revoked the account that had been created with “Sign in with Apple”.
 And the application no longer appears in the list of applications in the Connection and Security > Connection with Apple from iPhone section. However, when I click on the “Sign in with Apple” button again, I don’t see the window that asks me if I want to share my connection information. The app behaves as if I was simply logged out but when I enter my iCloud password I am logged in except in reality it is a new account. 
When I look in Firebase I have a new id for my user.
  In addition, the user is not really connected to the application since certain views behave as if the user session was empty. The only way is to erase the emulator and make a new build. I need help finding what's not working in my current code because I've been going around in circles for several days and I really don't understand what's going on. Here my entire AuthentificationViewModel: AuthentificationViewModel.txt
1
0
756
May ’24
Refresh view with new CloudKit records
Hello, I'm new to iOS development and I need help for working with CloudKit. I have an application that allows me to add, delete and display information stored in a CloudKit container. When I try to add a new record, this one can be visible into my CloudKit Console but if don't switch to a other view and back to my view (with my list of records) the record isn't displayed. How can I update my list to reflect directly the new record add to my container ? This is my code with split into different files (in attachment) Sets : define my record struct SetsView: list of my records AddSetView: add new records AddSetView-ViewModel : view model with my add function SetsView-ViewModel: view model with my fetch function Add function : func add() async throws { var newSet = set newSet.name = name newSet.code = code newSet.releaseDate = releaseDate newSet.numberOfCards = numberOfCards let record = try await db.save(newSet.set) guard let set = Set(record: record) else { return } setsDictionary[set.id!] = set print("Set added") } Fetch function : func fetchSets() async throws { let query = CKQuery(recordType: SetRecordKeys.type.rawValue, predicate: NSPredicate(value: true)) query.sortDescriptors = [NSSortDescriptor(key: "name", ascending: false)] let result = try await db.records(matching: query) // récupère les données qui correspondent aux critères let records = result.matchResults.compactMap { try? $0.1.get() } // Récupère les records sets.removeAll() records.forEach { record in sets.append(Set(record: record)!) } print("Sets fetched") print(sets) } Set.txt SetsView.txt AddSetView.txt AddSetView-ViewModel.txt SetsView-ViewModel.txt I try to add some print to figure out what's going on, but I don't understand. This is the console log for this scenario : open app without any data into the container > add a new record First, the fetch function is executed but there is no data into the container (it's logic) Second I add a new record (Set) : Into the CloudKit console the new Set is visible So for refresh my view with this record I need to re-call the fetch function. I tried many things but nothing works. Even if the fetch function is called, the new record is not retrieved. Do you have any idea how to solve this problem? Thanks for your help.
0
0
699
Jul ’23