How to access already existing data in Realm cloud using Xamarin Forms?

ros
cloud

#1

Hi everyone,
I’m using Realm for my Xamarin forms App.I have synced my data in Sql server with Realm cloud.Now I want to view the data which is there in Realm cloud in my Xamarin Forms App.
I used code
public ListsViewModel()
{

        LogoutCommand = new Command(Logout);
        AddressCommand = new Command(AddList);
        //TaskLists = new IQueryable<Address>();
        IQueryable<Address> TaskLists = Enumerable.Empty<Address>().AsQueryable();
        
        //AddList();
    }

private void AddList()
{

        _realm = Realm.GetInstance();

        TaskLists =  _realm.All<Address>();
        
        TaskLists.Count();


    }

My TaskLists.Count() gives 0.But my ROS has the data from sql server and they both are in sync.But my Xamarin Forms app is not syncing with my ROS. I even tried using SyncConfiguration.
private async void AddList()
{
User user = null;
try
{
user = User.Current;
}
catch (Exception ex)
{
HandleException(ex);
}

        if (user == null)
        {
            try
            {
                user = await NavigationService.Prompt<LoginViewModel, User>();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
        else
        {
            var uri = user.ServerUri;
            Constants.Server.SyncHost = $"{uri.Host}:{uri.Port}";
        }

        var config = new SyncConfiguration(user, Constants.Server.SyncServerUri)
        {
            ObjectClasses = new[] { typeof(Address) }
        };

        _realm = Realm.GetInstance(config);
        //_realm = Realm.GetInstance();
      
        TaskLists =  _realm.All<Address>();
       
      
        _realm.Write(() =>
        {
            _realm.Add(new Address { ID = 8, ZipCode = "Judson123" });
        });
      
        TaskLists.Count();


    }

Still I’m not able to fix it.


#2

@Judson619 What do you variables/constants look like for opening a realm?

Are you using: https://myCloudROS.realm.io for LogIn

And realms://myCloudROS.realm.io for opening a realm?

What do the logs look like?


#3

Yes I’m using

public static Uri SyncServerUri => new Uri($"realms://{SyncHost}/~/realmNotificationXamarin");
 public static Uri AuthServerUri => new Uri($"https://{SyncHost}");

`For logging in to Realm cloud. There is no issue in login.The login takes place successfully.Only problem is that the the data is not getting synced @ianward


#4

This my log

127.0.0.1 - GET /realms/files/%2Ff7ccc3273f5a13e206f4c9af2c0574ea%2FRealmDemo21042018?shouldCreate=true&realmType=full HTTP/1.1 200 117 - 44.220 ms
http9:51:11 AM
100.96.91.15 - POST /auth HTTP/1.1 200 939 - 52.325 ms
http9:51:11 AM
127.0.0.1 - GET /health?thisInstance=true HTTP/1.1 200 2 - 0.481 ms
http9:51:30 AM
100.96.92.5 - GET /health HTTP/1.1 200 2 - 2.212 ms
http9:51:30 AM
100.96.75.58 - POST /auth HTTP/1.1 200 794 - 2.289 ms

#5

I have the same issue , not connect realm object server to xamrin forms


#6

I can see a new Realm getting added in the ROS.


The RealmDemo21042018 is my project.Even I synced that Realm aswell with my Sql server but the data inside that is not getting synced to my Xamarin Forms.I’m getting this in my Log file.
127.0.0.1 - GET /realms/files/%2Ff7ccc3273f5a13e206f4c9af2c0574ea%2FRealmDemo21042018?shouldCreate=true&realmType=full HTTP/1.1 200 117 - 0.721 ms


#7

@Judson619 Can you turn up to trace logging for both server and client and share logs?

Are you connecting with an admin user?