YapDatabase icon indicating copy to clipboard operation
YapDatabase copied to clipboard

didReceiveRemoteNotification not getting called iOS10

Open maxgarmar opened this issue 8 years ago • 5 comments

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:

  • Change for the new notification system.
#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 );  
             }  
         }];  
  • Changes for new deprecated methods on cloudkit framework :: inside of _createZoneSubscription
    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

maxgarmar avatar Sep 28 '16 17:09 maxgarmar

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

  • everything works fine on iOS 9 devices
  • on iOS 10 devices, didRegisterForRemoteNotificationsWithDeviceToken is called but didReceiveRemoteNotification never is. So remote updates are only applied when the app exits from background.

knokknok avatar Oct 02 '16 16:10 knokknok

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

maxgarmar avatar Oct 02 '16 16:10 maxgarmar

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

knokknok avatar Oct 02 '16 17:10 knokknok

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

uthiel avatar Nov 01 '16 21:11 uthiel

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

uthiel avatar Nov 01 '16 22:11 uthiel