Uploaded image for project: 'Realm Cocoa SDK'
  1. Realm Cocoa SDK
  2. RCOCOA-331

Cannot open Read Only Synced Realms without internet connection

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      Goals

      Trying to use a read-only synced realm to propagate data to clients. This will require reliable opening of the realm, with (after sync) or without internet connection (using cached local copy) at the time of application startup.

      Expected Results

      An API to reliably open a read only synced realm during application launch.

      Actual Results

      When online, Realm syncs and then opens with Async API (correct). Note: Read only synced realms can only be opened with AsyncOpen because conventional open will write data to the realm, according to other threads.

      When offline, AsyncOpen will not return (to completion block) as it cannot connect to the server. Which is right, but leaves us with no way to open the realm.

      RLMSyncManager error handler reports error with RLMSyncSession.

      Steps to Reproduce

      Async open a read only synced realm. Try again when disabling Internet connection.

      Code Sample

      NSURL *syncServerURL = [NSURL URLWithString: @"XXXXXXX"];
      
      RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
      
      config.syncConfiguration = [[RLMSyncConfiguration alloc] initWithUser:loggedInUser realmURL:syncServerURL];
      
      
      // Open the remote Realm
      [RLMRealm asyncOpenWithConfiguration:config
                             callbackQueue:dispatch_get_main_queue()
                                  callback:^(RLMRealm *realm, NSError *error)
       {
           if  (error)
           {
               NSLog(@"Error opening racing realm: %@", error);
               
           }
           else
           {
               if (realm)
               {
                   NSLog(@"Opened Racing Realm");
                   
               }
               else
               {
                   NSLog(@"Error opening racing realm: Unspecified error");
                   
               }
           }
       }];
      

      Version of Realm and Tooling

      Realm framework version: 2.8.3

      Realm Object Server version:

      Xcode version: 8.3

      iOS/OSX version: 10

      Dependency manager + version: CocoaPod

            Assignee:
            nathan.contino@mongodb.com Nathan Contino (Inactive)
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: