예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;
            Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
            Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);
            base.OnCreate(savedInstanceState);

            global::Xamarin.Forms.Forms.SetFlags(new[] { "CollectionView_Experimental", "Shell_Experimental" });
            Xamarin.FormsMaps.Init(this, savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            LoadApplication(new App());

            //CreateNotificationChannel();

            IsPlayServicesAvailable();
            Log.Debug(TAG, "InstanceID token: " + FirebaseInstanceId.Instance.Token);
            var token = FirebaseInstanceId.Instance.Token;

            //CONSULTAR BD
            userdb = new UserDataBase();
            var userW       = new User();
            var user_exista = userdb.GetMembers().ToList();
            var user_exist  = userdb.GetMembers();
            int RowCount    = 0;
            int usercount   = user_exist.Count();

            RowCount = Convert.ToInt32(usercount);
            if (RowCount > 1)
            {
                userdb.DeleteMembers();
                userW.token  = token;
                userW.status = 0;
                userdb.AddMember(userW);
            }
            else if (RowCount == 1)
            {
                userdb.UpdateMemberToken(user_exista[0].id, token);

                /*if (token != user_exista[0].token)
                 * {
                 *
                 * }*/
            }
            else
            {
                if (token == null || token == "")
                {
                    FinishAffinity();
                }
                userW.id_cliente = 0;

                userW.name           = "";
                userW.nombre         = "";
                userW.password       = "";
                userW.username       = "";
                userW.remember_token = "";
                userW.google_id      = "";
                userW.email          = "";
                userW.token          = token;
                userW.status         = 0;
                userdb.AddMember(userW);
            }
        }