private void InitFireBase() { _isInit = false; #if FIREBASE && !UNITY_EDITOR Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; if (dependencyStatus == Firebase.DependencyStatus.Available) { // Create and hold a reference to your FirebaseApp, i.e. // app = Firebase.FirebaseApp.DefaultInstance; // where app is a Firebase.FirebaseApp property of your application class. _fireBase = Firebase.FirebaseApp.DefaultInstance; Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(true); // Set a flag here indicating that Firebase is ready to use by your // application. _isInit = true; } else { UnityEngine.Debug.LogError(System.String.Format( "Could not resolve all Firebase dependencies: {0}", dependencyStatus)); // Firebase Unity SDK is not safe to use here. } }); #endif }
public virtual void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(this.gameObject); } Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; if (dependencyStatus == Firebase.DependencyStatus.Available) { // Create and hold a reference to your FirebaseApp, // where app is a Firebase.FirebaseApp property of your application class. app = Firebase.FirebaseApp.DefaultInstance; InitializeFirebase(); // Set a flag here to indicate whether Firebase is ready to use by your app. } else { #if UNITY_EDITOR || DEVELOPMENT_BUILD UnityEngine.Debug.LogError(System.String.Format("Could not resolve all Firebase dependencies: {0}", dependencyStatus)); #endif } }); }
protected override void OnCreate(Bundle savedInstanceState) { // Well, just config with your own name app in manifest.xml // and yout own "google-services.json" file config from Firebase. that's all. base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); fireApp = Firebase.FirebaseApp.InitializeApp(this); fireFirestore = Firebase.Firestore.FirebaseFirestore.Instance; fireDatabase = Firebase.Database.FirebaseDatabase.Instance; Button btn1 = FindViewById(Resource.Id.Button1) as Button; btn1.Click += delegate { // So here it's crash the App. DocumentReference docRef = fireFirestore.Collection("collection1").Document("doc1"); docRef.Get() .AddOnCompleteListener(this) .AddOnFailureListener(this); }; }
private void Awake() { if (Application.platform != RuntimePlatform.Android) { return; } Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { if (task.Result == Firebase.DependencyStatus.Available) { Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance; IsFirebaseInited = true; } }); _errorCatcher.EvExceptionCaught += LogModelToCrashlystic; _waitScreen.EvSkipByAd += () => LogEventAd("wait"); _waitNotif.EvNotifChanged += LogEventNotifChanged; _tasks.ForEach(t => t.EvTaskEnd += LogEventTaskEnd); _publishScreen.EvPublished += LogEventNewsDone; _publishScreen.EvRewriteByAd += () => LogEventAd("rewrite"); _homeScreen.EvCheckEnd += LogEventHomeEnd; _homeScreen.EvAgainByAd += () => LogEventAd("home"); _weekOverScreen.EvWeekOver += LogEventWeekEnd; _endScreen.EvGameEnd += LogEventGameEnd; _reviewPopup.EvReviewPosted += LogEventReviewPosted; }
public static void Init(Android.Content.Context context) { var baseOptions = Firebase.FirebaseOptions.FromResource(context); var options = new Firebase.FirebaseOptions.Builder(baseOptions).SetProjectId(baseOptions.StorageBucket.Split('.')[0]).Build(); app = Firebase.FirebaseApp.InitializeApp(context, options, AppName); }
public static void Init(Android.Content.Context context) { var baseOptions = Firebase.FirebaseOptions.FromResource(context); // This HACK will be not needed, fixed in https://github.com/xamarin/GooglePlayServicesComponents/commit/723ebdc00867a4c70c51ad2d0dcbd36474ce8ff1 var options = new Firebase.FirebaseOptions.Builder(baseOptions).SetProjectId(baseOptions.StorageBucket.Split('.')[0]).Build(); app = Firebase.FirebaseApp.InitializeApp(context, options, AppName); }
public static void Init() { if (_app == null) { var context = Android.App.Application.Context; var baseOptions = Firebase.FirebaseOptions.FromResource(context); var options = new Firebase.FirebaseOptions.Builder(baseOptions).SetProjectId(baseOptions.StorageBucket.Split('.')[0]).Build(); _app = Firebase.FirebaseApp.InitializeApp(context, options, "Plugin.CloudFirestore"); } }
public async Task <string> GetAllImageUrlsFromServer() { string response = ""; /* * try * { * Firebase.FirebaseApp fireBaseApp = Firebase.FirebaseApp.Instance; * FirebaseStorage storageImage = FirebaseStorage.GetInstance(fireBaseApp, "gs://mytestfirebproj.appspot.com"); * //storageImage.Reference.Child() * ////Firebase.FirebaseApp fireBaseApp = Firebase.FirebaseApp.Instance; * ////FirebaseStorage storage = FirebaseStorage.GetInstance(fireBaseApp); * //var stroageImage = await new FirebaseStorage("xamarinfirebase-d3352.appspot.com") * //.Child("XamarinMonkeys") * //.Child("image.jpg") * //.PutAsync(imageStream); * //string imgurl = stroageImage; * //return imgurl; * } * catch(Exception ex) * { * var msg = ex.Message + "\n" + ex.StackTrace; * System.Diagnostics.Debug.WriteLine(msg); * } */ try { AndroidConversionService androidConversionService = new AndroidConversionService(); var streamResponse = await androidConversionService.GetStreamFromLocalFileURL(""); Firebase.FirebaseApp fireBaseApp = Firebase.FirebaseApp.Instance; //FirebaseStorage storageImage = FirebaseStorage.GetInstance(fireBaseApp, "gs://mytestfirebproj.appspot.com"); var storageImage = FirebaseStorage.GetInstance(fireBaseApp, FirebaseAppInstance).Reference.Child("FireBaseTestImageOne"); //storageImage.Reference.Child() ////Firebase.FirebaseApp fireBaseApp = Firebase.FirebaseApp.Instance; ////FirebaseStorage storage = FirebaseStorage.GetInstance(fireBaseApp); //var stroageImage = await new FirebaseStorage("xamarinfirebase-d3352.appspot.com") //.Child("XamarinMonkeys") //.Child("image.jpg") //.PutAsync(imageStream); //string imgurl = stroageImage; //return imgurl; } catch (System.Exception ex) { var msg = ex.Message + "\n" + ex.StackTrace; System.Diagnostics.Debug.WriteLine(msg); } return(response); }
private void InitFirebase() { Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; if (dependencyStatus == Firebase.DependencyStatus.Available) { // Create and hold a reference to your FirebaseApp, // where app is a Firebase.FirebaseApp property of your application class. // Crashlytics will use the DefaultInstance, as well; // this ensures that Crashlytics is initialized. Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance; _isFirebaseInitializeDone = true; } else { UnityEngine.Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}"); } }); }
public static void ChecAndTryInit(System.Action callback) { if (HasInstance) { callback(); } else if (sIsInitializing) { EventOnInitSuccess += callback; } else { sIsInitializing = true; EventOnInitSuccess += callback; Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; if (dependencyStatus == Firebase.DependencyStatus.Available) { sInstance = Firebase.FirebaseApp.DefaultInstance; if ((object)EventOnInitSuccess != null) { EventOnInitSuccess(); EventOnInitSuccess = null; } } else { UnityEngine.Debug.LogError(System.String.Format( "Could not resolve all Firebase dependencies: {0}", dependencyStatus)); // Firebase Unity SDK is not safe to use here. } sIsInitializing = false; }); } }
public AndroidFireBaseAuthenticationService() { Firebase.FirebaseApp fireBaseApp = Firebase.FirebaseApp.Instance; authInstance = FirebaseAuth.GetInstance(fireBaseApp); }