0

I have created cksubscription with alertBody programatically and it works fine.For testing purpose at development environment,I deleted that subscription from cloudkit dashboard(not using code) and again created cksubscription with different alertBody using same code. After creating this I got 2 Alert message with both alertbody. I am not getting what's the problem? At dashboard it shows only one subscription type and when push notification fire is shows 2 message.

Does anyone know how to resolve it?

János
  • 32,867
  • 38
  • 193
  • 353
bittu
  • 683
  • 7
  • 24

1 Answers1

0

In the dashboard you will only see the subscriptions that are setup for the user where you loged in into the dashboard. When you remove that subscription, then you will only remove it for that user. If your device is loged in with a different user, then the old subscription will still be there.

You could check for available subscriptions at runtime. You could use code like this:

    self.database.fetchAllSubscriptionsWithCompletionHandler({subscriptions, error in
            for subscriptionObject in subscriptions! {
                if let  subscription: CKSubscription = subscriptionObject {
                    self.database.deleteSubscriptionWithID(subscription.subscriptionID, completionHandler: {subscriptionId, error in
...
Edwin Vermeer
  • 13,017
  • 2
  • 34
  • 58
  • I logged in with same user.still it shows 2 alert msg. – bittu Oct 28 '15 at 14:01
  • could you try to do a fetchAllSubscriptionsWithCompletionHandler and log the subscription to see if you do have 2 subscriptions? You should have more than 1 subscription. – Edwin Vermeer Oct 29 '15 at 07:03
  • I used it and log the subscription to see whether I have 2 subscription or not and it display 0 subscription.I am using objective c so I code it like: CKDatabase *publicDatabase = [[CKContainer defaultContainer] publicCloudDatabase]; [publicDatabase fetchAllSubscriptionsWithCompletionHandler:^(NSArray *subscriptions, NSError *error) { NSLog(@"subscription----------%lu",(unsigned long)subscriptions.count); for (CKSubscription * subscriptionObject in subscriptions) { NSLog(@"sub-----%@",subscriptionObject); } – bittu Oct 29 '15 at 08:21
  • That sounds like your container is corrupt. Probably the only way to solve that is by resetting your container from the CloudKit dashboard – Edwin Vermeer Oct 29 '15 at 11:24
  • do you know how to reset container?I didn't find proper post for it. – bittu Oct 30 '15 at 05:21
  • Open the CloudKit dashboard (In you app, go to the project target, capabilities and press the CloudKit dashboard button. Then select the container that you want to reset, Klik on deployment and then click on reset development environment. – Edwin Vermeer Oct 30 '15 at 06:19