How to make remote notifications work with CloudKit Subscriptions?
Asked Answered
T

1

20

So far I was unable to make subscriptions to work. (receive a push notification on my device, subscriptions appears to be created successfully)

I have been playing with [CloudKitAtlas][1]. I did what it's told on the readme for that proyect:

Requirements

Build

  • iOS 8.0 SDK and Xcode 6
  • Enable the CloudKit entitlement in iCloud (from Capabilities)
  • Change your container name to provision a container in your developer account

I'm able to launch the app, it registers successfully for remote notifications:

2014-06-09 11:15:17.712 CloudKitAtlas[841:220562] Registered for Push notifications with token:

I'm also able to create records, query them and subscribe:

2014-06-09 11:15:21.966 CloudKitAtlas[841:220934] Subscribed to Item

And if I go to the dashboard I see several subscriptions created. But then when I create a new record nothing happens, the callback:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)info

Is never executed (Note: I'm running the app on a iPhone 5S, not on the simulator)

I'm using a debug signature with explicit bundle id (no wildcard) and for this app id I also created the corresponding push notifications certificates although I just downloaded them as I have nothing to do with those files.

  1. Am I forgetting to do something?
  2. Am I not testing it properly?
  3. Does anyone manage to get remote notifications on his device triggered by a subscription?

Update 15 / 06 / 14 Apparently it's a bug on apple side, let's wait a couple of weeks. https://developer.apple.com/library/content/samplecode/CloudAtlas/Introduction/Intro.html#//apple_ref/doc/uid/TP40014599


Update 18 / 05 / 15

In case anyone is wondering this bug was resolved by Apple long time ago and now it works like a charm, although you need to make some considerations:

  1. Make sure the saveSubscription:completionHandler: method executes without errors
  2. If you use [application registerForRemoteNotifications]; You will ONLY get notifications with the app on foreground, it might look like is pointless but it is very useful as this kind of push notifications are "silent" and you don't require user permission to use them
  3. If you want to get old fashion push notifications with the pop up asking for permission and an alert that appears outside of the app and everything you need to use something like:
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:
                                        UIUserNotificationTypeBadge |
                                        UIUserNotificationTypeSound |
                                        UIUserNotificationTypeAlert
                                                                         categories:nil];
    

    [application registerUserNotificationSettings:settings];

That's all

Tedric answered 13/6, 2014 at 3:25 Comment(5)
I've also had the same issue. I assume maybe it's just a sandbox environment issue? That or we need to configure push too for subscription pushes to function...?Quintie
Push notifications works on sandbox mode so It should work here too. I have the feeling that I'm forgetting to setup something :(Tedric
Does it work on the new beta 2 ?Meagre
I tried this morning and nothing :| I need to try with a fresh new app and a fresh new container, maybe that matters too. Also no mention about this issue on the changelog for beta 2Tedric
How to set up a minimal subscription in CloudKit: #24905890Insular
I
-1

registerForRemoteNotificationTypes:types NS_DEPRECATED_IOS(3_0, 8_0, "Please use registerForRemoteNotifications and registerUserNotificationSettings: instead");

// Returns the enabled types, also taking into account any systemwide settings; doesn't relate to connectivity.

enabledRemoteNotificationTypes NS_DEPRECATED_IOS(3_0, 8_0, "Please use -[UIApplication isRegisteredForRemoteNotifications], or -[UIApplication currentUserNotificationSettings] to retrieve user-enabled remote notification and user notification settings");

That from iOS8 it becomes deprecated is not cause, probably will be?

Ibbison answered 26/6, 2014 at 10:17 Comment(1)
I'm using "registerForRemoteNotifications" and I check with "isRegisteredForRemoteNotifications" and it is registered, besides I'm using Apple's example of CloudKit. I really think it is a bug on their side.Tedric

© 2022 - 2024 — McMap. All rights reserved.