CloudKit Error "User Deleted Zone" (28/2042) - ios

In my app, one of my users is no longer able to access the application iCloud container. The log file contains these errors:
<CKError <redacted>: "User Deleted Zone" (28/2042);
server message = "Zone was purged by user";
uuid = <redacted>; container ID = "iCloud.<redacted>">
Has anyone an idea on what the user may have done to unlink the app from his iCloud storage?
How should I react within my application to this error to get it "back on track"?

This error is triggered when the user deletes your application data from Settings > iCloud > Storage > Manage Storage. You will not be able to test this in the Development environment, you need to debug in Production. See https://stackoverflow.com/a/33432068/138820
To get back on track, you just need to save the zone. If you keep server change tokens from fetches, you have to delete that as well, or you’ll keep getting the error when fetching

Related

Why am I receiving a 'Multiple Sync Agents' error and 'Client Reset Error'?

I am utilising the Template App, provided by MongoDB Realm, available here: https://www.mongodb.com/docs/atlas/app-services/reference/template-apps/ (swiftui.todo.flex).
I am using SwiftUI, with Swift.
The app works correctly, apart from one aspect - when I log in as 'User 1' (arbitrary reference) it is successful - then, if I log out, and log back in (on the same device - i.e. the iOS simulator) as 'User 2', the login is successful but then I receive a recurring error message which reads 'Automatic Client Reset Failed' and the code eventually crashes with the following:
Received: ERROR "User mismatch for client file identifier (IDENT)"
(error_code=223, try_again=true, error_action=ClientReset)
libc++abi: terminating with uncaught exception of type realm::MultipleSyncAgents: Multiple sync agents attempted to join the
same session
Realm documentation states the 'Multiple User Systems' is compatible with their product, and that there should be no issues operating multiple users on the same device.
Realm logs show a "ClientFileUserMismatch Error". I suspect that the app is trying to open the pre-existing Realm file using the new user's credentials, which is causing the error? But I'm unsure of how to resolve this - and I'm surprised that this error appears in their template code?
Can anyone assist me please?

iOS Cognito error 13 on one device but success on another

I am running into a strange problem where the user was able to log in previously and now getting error 13 - Temporary password has expired and must be reset by an administrator. However, switching to a different device using the app login succeeds. Any ideas what needs to be done to clear cache or keys or anything else that is needed?

Keychain access error 25308 (errSecInteractionNotAllowed)

In one of my iOS app, I am seeing multiple crashes while accessing the Keychain (in both cases i.e. setting an item & getting an item) and the error code is 25308.
Few details:
1) I am using a 3rd party keychain wrapper https://github.com/kishikawakatsumi/KeychainAccess
2) The accessibility option is set to 'whenUnlockedThisDeviceOnly'
3) This is not happening to all users. I am unable to reproduce it by any chance.
4) I am accessing keychain at few places in AppDelegate. Few crashes are reported on app launch and few are reported on Firebase token refresh notification observer method.
5) In didFinishLaunch, I am trying to access the value for a keychain item where as in Firebase token refresh, I am trying to set the new token value to the keychain.
On my findings I understood that this error code 25308 will be returned when user tries to access the keychain when a device is in locked state. But my Fabric (crash reporting tool) shows that the 'App is in Focus' in all these crashes.
So this got me confused with multiple questions like:
1) What else cases can throw this error 25308 other than device unlocked state?
2) Does firebase token refresh notification causes this background launching of app ? If so, how can I reproduce this. (One supporting thing here is I know that app was not uninstalled)
Update on 01/03:
It seems like the root cause for this is 'App is being launched when Firebase generates a new token and this launch is happening when device is in locked state, hence keychain access is throwing such error 25308.' So is anyone aware how a new firebase token launches the app which is already in terminated state??
Appreciate your responses on this. Thanks..

Firebase database offline cache not working between launches

I'm trying to use Firebase for a partially offline app, it seems to have all the offline capabilities I need but I'm having issues with fetching data while offline. The JSON structure I want to store is a single reference to a user profile:
{
"Profiles" : {
"pOnv3q1PxqPyqKH0uqtDYaXqvqF2" : {
"firstName" : "John",
"lastName" : "Doe"
}
}
}
I've set Database.database().isPersistenceEnabled = true and keepSynced(true) set for the reference I want to keep cached offline. I set keepSynced(true) both when I create the reference the first time and when I load it on subsequent launches.
Scenario 1 - Works
If I launch the app online, the reference is created and saved to the online database. If I close the app with it still online and fully kill it, then relaunch, the reference is found as you'd expect.
Scenario 2 - Works
I launch the app offline, create the reference offline and save it to the cache. I fully kill the app and relaunch it and then reconnect, the reference is pushed to the online database from the cache as you'd expect.
Scenario 3 - Does not work
I launch the app online, create the reference and exit while still online. I kill the app and then relaunch it offline, only to find that the reference had not been stored in the cache and isn't being loaded.
These scenarios seem to me like the requests to the online database are being successfully cached, but the database itself is not.
Am I misunderstanding the Firebase offline functionality or should this be working? It's worth noting that this is in Xcode9, iOS11 and Swift 4 so there may be compatibility issues.
The code I'm using to fetch this reference is:
Database.database().child("Profiles").child(userId).observeSingleEvent(of: .value) { snapshot in
print(snapshot)
}
On failed fetches this is returning an empty snapshot. I was under the impression that if the local cache had no idea of the presence of a key then the completion handler wouldn't be called, however it is being called leading me to think that the key exists but the data isn't being fetched properly.
Ideally the user would be able to sign up offline and have basic functionality, then push the data when a connection is established, but currently the profile can only be loaded with a connection available.
Any help would really be appreciated.

iCloud Core Data not syncing

I think I did everything I could find on tutorials and apple's documentation.
But my Core Data do no get out of my iOS device to the iCloud servers.
In short, the following calls are made :
Get Ubiquity token and check that user wants to use iCloud - done - works OK
Connect to Ubiquity containers using URLForUbiquityContainerIdentifier: - done - though this should be useless (according to a previous discussion thread)
Registered to receive and handle NSPersistentStoreCoordinatorStoresWillChangeNotification, NSPersistentStoreCoordinatorStoresDidChangeNotification, NSPersistentStoreDidImportUbiquitousContentChangesNotification notifications
I do see in the console the messages :
-[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](771): CoreData: Ubiquity: mobile~xxxx
Using local storage: 1
and
-[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](771): CoreData: Ubiquity: mobile~xxxx
Using local storage: 0
and my handlers are called.
I can use the app perfectly in the iOS device, but no data is uploaded to iCloud.
When I delete the app from the device, iOS ask me confirmation if I really want to delete the app, and then asks for a second confirmation because "some iCloud data is pending upload, and I will loose them".
I checked that data could be pending for more than 24 hours.
And, of course, my iOS device has network and iCloud is working fine.
Any idea of what I could have done stupidly ?
I got it back to work.
Actually, I did not change anything. But I fully restored the iOS device.
Any explanations will be welcome.

Resources