yapstudios / YapDatabase

YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers.
Other
3.35k stars 363 forks source link

didReceiveRemoteNotification not getting called iOS10 #369

Open maxgarmar opened 8 years ago

maxgarmar commented 8 years ago

Hello guys!

I am working to update my app to the latest features that iOS 10 offers. Sharing cloudkit, siri, ... I am using your yapDatabaseCloudKitExtension to avoid dealing with ugly local data caching. Problem is when I run the code for iOS 9 from your example, everything fine, didReceiveRemoteNotification is called by cloudkit so it merges the changes on the fly. Problem is on iOS 10, after I change some code to adapt the deprecated code didReceiveRemoteNotification is not getting called at all.

Changes below:

#import <UserNotifications/UserNotifications.h>

@class AppDelegate;

@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

....

 UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
        center.delegate = self;
        [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
         {
             if( !error )
             {
                 [[UIApplication sharedApplication] registerForRemoteNotifications];  // required to get the app to do anything at all about push notifications
                 NSLog( @"Push registration success." );
             }
             else
             {
                 NSLog( @"Push registration FAILED" );
                 NSLog( @"ERROR: %@ - %@", error.localizedFailureReason, error.localizedDescription );
                 NSLog( @"SUGGESTIONS: %@ - %@", error.localizedRecoveryOptions, error.localizedRecoverySuggestion );  
             }  
         }];  
    CKRecordZoneID *recordZoneID =
      [[CKRecordZoneID alloc] initWithZoneName:CloudKitZoneName ownerName:CKCurrentUserDefaultName];
    CKRecordZoneSubscription *subscription =
      [[CKRecordZoneSubscription alloc] initWithZoneID:recordZoneID subscriptionID:CloudKitZoneName];

What am I doing wrong ? I don't see anything different on apple documentation. I am getting normal push notifications on this device when I send them from a test notification app. So notifications are correctly activated. Perhaps the problem is when I subscribe to the zone or something like that. Would be great if you guys can update the code of the example to work with iOS 10 and Xcode 8. Anyway you made a great work with this extension.

Thanks !!

Maxi

knokknok commented 8 years ago

Any luck? I get the same issue: Using the identical application:

maxgarmar commented 8 years ago

No luck so far @knokknok, I am searching for other options, like ensemble or something like that. I tried everything without success. I think that really, there are many changes from iOS 9 to iOS 10 in cloudKit, notifications, .. and without the help of the API creators, will be difficult or perhaps impossible without touching the core. Let me know if you get farer than me.

Thanks

knokknok commented 8 years ago

Thanks for your answer... I'm stuck too :-( @robbiehanson, did you manage to get the CloudKitTodo example to work with iOS 10?

uthiel commented 8 years ago

Remote notifications did work for me for a few hours, then they stopped working about 30 minutes ago...that's on 10.1.

uthiel commented 8 years ago

I figured shouldSendContentAvailable = YES; will result in didReceiveRemoteNotification getting called on my iOS 10 device.