caiyue1993 / IceCream

Sync Realm Database with CloudKit
MIT License
1.93k stars 243 forks source link

watchOS 6 support #186

Open martindaum opened 4 years ago

martindaum commented 4 years ago

I'll try to get IceCream working on an independent watch app with watchOS 6. I enabled subscriptions and they get created as expected. The sync is basically working when using the pull & pushAll methods, but it seems the watch app does not get any push notifications from CloudKit. I registered via WKExtension.shared().registerForRemoteNotifications(), but nothing is delivered. Any idea if I am missing something else?

    func createDatabaseSubscriptionIfHaveNot() {
        if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 6.0, *) {
            guard !subscriptionIsLocallyCached else { return }
            let subscription = CKDatabaseSubscription()
            let notificationInfo = CKSubscription.NotificationInfo()
            notificationInfo.shouldSendContentAvailable = true // Silent Push
            subscription.notificationInfo = notificationInfo

            let createOp = CKModifySubscriptionsOperation(subscriptionsToSave: [subscription], subscriptionIDsToDelete: [])
            createOp.modifySubscriptionsCompletionBlock = { _, _, error in
                guard error == nil else { return }
                self.subscriptionIsLocallyCached = true
            }
            createOp.qualityOfService = .userInteractive
            database.add(createOp)
        }
    }

That is the code I have changed to get the subscription working on watchOS 6.

mrezk commented 1 year ago

hi @martindaum, did you manage to get IceCream to work in watchOS?

martindaum commented 1 year ago

No, but I stopped trying!