Based on reported events and generated analysis future steps can be taken. More with tracking user properties, firebase analytics also provide a way to track events from an application to be reported on Firebase console. GET A FREE QUOTE ON YOUR PROJECT! Track Events See the updated code snippet below.įuture String? String? String? userRole,Īwait _tUserProperty(name: ‘login_type’, value: loginType) Īwait _tUserProperty(name: ‘user_role’, value: userRole) Īwait _tUserProperties( This is about user id but apart from this we can also track user defined properties like login type & role and to do that let’s accept another string parameters on same function and add that to analytics. Simulation can be done using below code snippet.Īwait layed(Duration(milliseconds: 3000)) Īwait _tUserId(id: ‘101’) To do that we have to add a function accepting a string parameter called id & will registering that as user id on analytics. Once we do that, we can check reported events in section titled Realtime under Analytics portion on Firebase Console.Īnother benefit of having firebase analytics is we can track user properties like id, type of login, role & etc and get that information on analytics at Firebase console.įirst, we’ll track user id and to simulate this flow we can put some delay before moving ahead with registering user id into analytics. As of now we do have 3 screens where we can move around, Login, Register and Forgot Password. See the code below to do that.Īfter specifying class in navigatorObservers run the app and start moving around the different screens inside app. In our FirebaseAnalyticsService class we have FirebaseAnalyticsObserver added which can be added to navigatorObservers to track screen view events. ServiceLocator.registerLazySingleton(() => FirebaseAnalyticsService()) įrom this point, our FirebaseAnalytcicsService class is ready to use for different usage of Firebase Analytics. Now register this class in our servicelocator file: Import ‘package:firebase_analytics/observer.dart’ įinal FirebaseAnalytics _analytics = FirebaseAnalytics() įirebaseAnalyticsObserver appAnalyticsObserver() =>įirebaseAnalyticsObserver(analytics: _analytics) Import ‘package:firebase_analytics/firebase_analytics.dart’ Now define a new class named FirebaseAnalyticsService and put below displayed code. Once done we’re ready to move ahead with new steps. Before integrating analytics, we have to integrate firebase core to our flutter project. To integrate firebase analytics for our flutter project, follow steps provided here in their official details. To build up future updates around the activities user has performed & we have tracked so far. So, let’s start understanding how to integrate firebase analytics for a Flutter Application and get best use of generated analytics. Even for more, we can filter this all on the basis of Platform, Stream, Users custom data (like Gender, Age and etc.) & Signed in Status also. Firebase analytics get us more in-depth details of application details like active users, top conversation events, daily user engagement, crash free user percentage and more. addUserInfoToDB(į("users").doc(userID).Having firebase integrated to our Flutter applications has brought us many advantages. Then add the sha1 key to firebase> project settings > Add fingerprint > Save.Ĭreate a file in services/database.dart create a class called DatabaseMethods and add this function to it. Run this command in terminal/cmd link to answer on stackoverflow keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android Step6: Add Sha1 key to firebase project to make google sign in work properly Step5: Connect flutter app with firebase. so create a folder helperfun/sharedpref_helper.dart file. Step4: Create function to get and save data with sharedpreference. Step2: Import required packages in pubspec.yaml firebase_auth:įor this we will create a folder called services/auth.dart fileĪs you can see in auth.dart once the user is signed in we save user info to local database with sharedpreference so we need to create those functions. Step1: Creating Flutter project & Refactor Code Send user message real time (it’s better).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |