Exemple #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            FirebaseOptions.Builder builder = new FirebaseOptions.Builder();
            builder.SetApiKey("AIzaSyAe9KR6oAI5yZ6Y3RsR2-I_VWCAg4ut4ek");
            builder.SetApplicationId("1:471441222469:android:fcf08d13fa42ec25");
            builder.SetDatabaseUrl(GetString(Resource.String.firebase_url));
            builder.SetProjectId("xztalk-51c5e");

            FirebaseOptions firebaseopt = builder.Build();
            FirebaseApp     firebaseapp = FirebaseApp.InitializeApp(this, firebaseopt);

            database = FirebaseDatabase.GetInstance(firebaseapp);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.main);



            fab     = FindViewById <FloatingActionButton>(Resource.Id.fab);
            edtChat = FindViewById <EditText>(Resource.Id.input);
            lstChat = FindViewById <ListView>(Resource.Id.list_of_messages);

            fab.Click += delegate { PostMessage(); };

            if (FirebaseAuth.Instance.CurrentUser == null)
            {
                StartActivityForResult(new Android.Content.Intent(this, typeof(SignIn)), MyResultCode);
            }
            else
            {
                Toast.MakeText(this, "Welcome" + FirebaseAuth.Instance.CurrentUser.Email, ToastLength.Short).Show();
                DisplayChatMessage();
            }
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);
            global::Xamarin.Forms.Forms.Init(this, bundle);
            CurrentActivityRef = this;
            var builder = new FirebaseOptions.Builder();

            builder.SetApiKey("AIzaSyAaDvgA60S659P6DDZoAXx_HxEnQGwHw-8");
            builder.SetProjectId("task-manager-99e87");
            builder.SetStorageBucket("task-manager-99e87.appspot.com");
            builder.SetApplicationId("1:358089600915:android:01c3cfbae105ed8331c266");
            var options = builder.Build();

            FirebaseApp.InitializeApp(this, options);
            LoadApplication(new App(new Setup()));
        }