bugthesystem / FireSharp

An asynchronous cross-platform .Net library for Firebase
The Unlicense
697 stars 147 forks source link

I can't use OnAsync in Xamarin IOS #97

Closed cuong95nddev closed 7 years ago

cuong95nddev commented 7 years ago

Here my code `using FireSharp; using FireSharp.Config; using FireSharp.Interfaces; using FireSharp.Response; using System;

using UIKit;

namespace Chat { public class ChatMessage { public string name { get; set; } public string text { get; set; } } public partial class ViewController : UIViewController { private const string BasePath = "https://chat-c642c.firebaseio.com/"; private const string FirebaseSecret = "RxIsctLdNZeV110WJ6PP0QtOPIwj9R1Fm5Tn9N3G"; private static FirebaseClient _client;

    public ViewController(IntPtr handle) : base(handle)
    {
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        // Perform any additional setup after loading the view, typically from a nib.

        IFirebaseConfig config = new FirebaseConfig
        {
            AuthSecret = FirebaseSecret,
            BasePath = BasePath
        };

        _client = new FirebaseClient(config);

        _client.OnAsync("chat",
            added: (s, args, context) =>
            {
                tvTest.Text = args.Data + " -> 1(ADDED)";
            },
            changed: (s, args, context) =>
            {
                tvTest.Text = string.Format("Data :{0}, Path: {1} -> 1(CHANGED)", args.Data, args.Path);
            },
            removed: (s, args, context) =>
            {
                tvTest.Text = args.Path + " -> 1(REMOVED)";

            });

    }

    public override void DidReceiveMemoryWarning()
    {
        base.DidReceiveMemoryWarning();
        // Release any cached data, images, etc that aren't in use.
    }

    partial void BtnTest_TouchUpInside(UIButton sender)
    {
        push();
    }

    async void push()
    {
        PushResponse response = await _client.PushAsync("chat/", new ChatMessage
        {
            name = "Win8",
            text = "hihi"
        });
    }
}

}`

cuong95nddev commented 7 years ago

Fixed by using xamarin on vmware instance of mac host