Search code examples
iosswiftamazon-web-servicesswiftuiaws-appsync

AWS Datastore not Syncing IOS


My Datastore is not syncing with my cloud instance and I dont know why! I am new to AWS but just followed the tutorial here: https://docs.amplify.aws/start/getting-started/integrate/q/integration/ios/#query-todos

I got as far as setting up my local datastore and adding/deleting/updating just fine. I know because I was able to print to my console the results of the saved items.

When it came to cloud syncing it was not as easy.

I have setup a subscription and it returns nothing. Furthermore when I use the graphQL console online I also do not see any data making me believe that the data is not synced at all.

I attempted to manually update the datasource and post the data with the command found here: https://docs.amplify.aws/lib/datastore/sync/q/platform/ios/#advanced-use-case---query-instead-of-scan

let sink = Amplify.DataStore.save(post, where: Post.keys.title.beginsWith("[Amplify]"))
.sink {
    if case let .failure(error) = $0 {
        print("Could not update post, maybe the title has been changed?")
    }
}
receiveValue: { _ in
    print("Post updated successfully!")
}

But i get the error post is not available in scope no matter where I try to integrate it.

Possible reasons for this: originally I was using congnito user pool but was getting errors so I switched to API key instead I was able to push successfully no problem. when

Now when I check amplify status I get no change for both my api and auth.

Any help would be greatly appreciated, thanks in advance!


Solution

  • So turns out, when I was testing bluetooth yesterday I had turned off wifi on my device. This is the reason why it was not syncing with my cloud integration. Hopefully this helps someone else but thank you to everyone who looked this over.

    Also: "Post" in above scenario refers to the tutorials Model Object. I did not realize this at first either.

    .. rough day to say the least