Posts

Post not yet marked as solved
0 Replies
485 Views
We need users to be able to scan multiple App Clip QR codes and start a new App Clip experience when they scan a new one. We use Scene and read the URL in the .onContinueUserActivity() method. We have also implemented the .onOpenURL() with the same behaviour. When the user scans the QR code for the first time, everything works fine - we get the URL and handle it correctly. Unfortunately, when she scans a second QR code (with different URL) while the App Clip is still running in the background, the phone just moves the appclip to the foreground and the user sees whatever was there the last time. As far as I can tell, the methods mentioned above won't get called. If we kill the app and scan the other QR code, it will work as expected - but we can't expect users to kill the app when they want to start a new experience. One issues is that I have no idea how to debug this scenario. Is there any way to simulate scanning a second QR code form XCode? As far as I know, I'd need to stop and start the app - which is a scenario I know to work fine. Can anyone think of a way of debugging this and/or tell what Scene or AppDelegate methods we need to implement for this to work? Thanks a lot
Posted
by tonycz.
Last updated
.
Post not yet marked as solved
0 Replies
383 Views
Hello there,in my app, I use a background contexts to synchronize data. Basically, all user data is in Core Data and when something changes, the background context will upload the changes to the server. Also, there is another context which polls the server every few minutes to see if there are any changes there. If so, it saves the changes to the local database.My current approach is, that when the application starts, I create a new background context (persistentContainer.newBackgroundContext()) and use it indefinetly.Obviously, the other approach would be to create a new background context everytime I need to run the synchronization and then throw it away when the synchronization finishes.I wonder which approach is better.For example, one issue I ran into is that the "long lived" backround context doesn't always see the changes made by other contexts. I use "automaticallyMergesChangesFromParent = true" but that doesn't seem to work in all cases. So, I ended up doing things like:self.backgroundContext.refresh(dbEntity, mergeChanges: true). My understanding is that the "parent" for backgroundContext is the actual SQLite database when the context is created using persistentContainer.newBackgroundContext()If someone has a link to an article which would clearly explain everything around ManagedObjectContexts and merging objects between them, I'd love to see it. I read a few articles but I still must be missing something.Thanks a lotTony
Posted
by tonycz.
Last updated
.
Post marked as solved
1 Replies
1.1k Views
Just a general question. This feature has been introduced couple years ago. There is still virtually no documentation for it (all the API pages say "No overview available.") and on the same API pages, one can read a "Beta Software warning".https://developer.apple.com/documentation/coredata/nspersistenthistorychangerequestI'm currently building my app around Persistent History Tracking and I wonder how big is the riskt of this feature to get removed from iOS 13 for example.Did anyone have any experience with similar features in the past? Is Apple likely to drop the support sudenly?Thanks
Posted
by tonycz.
Last updated
.
Post marked as solved
2 Replies
1.4k Views
I'm trying to use Persistent History Tracking to implement data synchronization with the server. The idea is that for every NSPersistentHistoryTransaction, I want to (eventually) make analogous REST requests to perform identical change on the server.My code iterates through all the changes in the transaction. When the change is a DELETE, I can't figure out, how to tell what object type was deleted. As far as I can tell, the only thing I've got is the tombstone - which are some of the original object's fields (externalId in my case). While ID is an identifier, I also need to know what entity that ID belongs to.The documentation for the whole Core Data feature is next to none :-/The only solution I could come up with is to add a new field to each entity. The field name is entityType, type is String and the default value is whatever the entity is. And I set the "Preserve After Deletion" for this field.This does solve the the problem. The drawback is that I store few extra bytes for every record I save.If anyone can think of a better solution, I'd love to see it.
Posted
by tonycz.
Last updated
.