protected override void OnStart() { base.OnStart(); mAuth.AddAuthStateListener(this); }
public override void OnCreate() { base.OnCreate(); RegisterActivityLifecycleCallbacks(this); //A great place to initialize Xamarin.Insights and Dependency Services! //If debug you should reset the token each time. #if DEBUG FirebasePushNotificationManager.Initialize(this, true); /*FirebasePushNotificationManager.Initialize(this, new NotificationUserCategory[] * { * new NotificationUserCategory("message",new List<NotificationUserAction> { * new NotificationUserAction("Reply","Reply",NotificationActionType.Foreground), * new NotificationUserAction("Forward","Forward",NotificationActionType.Foreground) * * }), * new NotificationUserCategory("request",new List<NotificationUserAction> { * new NotificationUserAction("Accept","Accept",NotificationActionType.Default,"check"), * new NotificationUserAction("Reject","Reject",NotificationActionType.Default,"cancel") * }) * * }, true);*/ #else FirebasePushNotificationManager.Initialize(this, false); /*FirebasePushNotificationManager.Initialize(this,new NotificationUserCategory[] * { * new NotificationUserCategory("message",new List<NotificationUserAction> { * new NotificationUserAction("Reply","Reply",NotificationActionType.Foreground), * new NotificationUserAction("Forward","Forward",NotificationActionType.Foreground) * * }), * new NotificationUserCategory("request",new List<NotificationUserAction> { * new NotificationUserAction("Accept","Accept",NotificationActionType.Default,"check"), * new NotificationUserAction("Reject","Reject",NotificationActionType.Default,"cancel") * }) * * },false);*/ #endif //Handle notification when app is closed here CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) => { System.Diagnostics.Debug.WriteLine("NOTIFICATION RECEIVED", p.Data); }; //Set the default notification channel for your app when running Android Oreo if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O) { //Change for your default notification channel id here FirebasePushNotificationManager.DefaultNotificationChannelId = "DefaultChannel"; //Change for your default notification channel name here FirebasePushNotificationManager.DefaultNotificationChannelName = "general"; } mAuth = FirebaseAuth.Instance; mAuthListener = new FirebaseAuthListener(); mAuth.AddAuthStateListener(mAuthListener); }