protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Bootstrap.Begin(() => new DeviceInstallationService()); if (DeviceInstallationService.NotificationsSupported) { FirebaseInstanceId.GetInstance(Firebase.FirebaseApp.Instance) .GetInstanceId() .AddOnSuccessListener(this); } Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); CurrentPlatform.Init(); string dbName = "smartsub_db.sqlite"; string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); string fullPath = Path.Combine(folderPath, dbName); LoadApplication(new App(fullPath)); }
public string TryForceTokenRefresh(string senderId) { string token = null; try { FirebaseApp firebaseApp = FirebaseApp.Instance; if (firebaseApp == null) { firebaseApp = FirebaseApp.InitializeApp(Application.Context, FirebaseOptions.FromResource(Application.Context)); } FirebaseInstanceId firebaseInstanceId = FirebaseInstanceId.Instance; if (firebaseInstanceId == null && firebaseApp != null) { firebaseInstanceId = FirebaseInstanceId.GetInstance(firebaseApp); } if (firebaseInstanceId != null && firebaseApp != null) { /// should force token to be refreshed firebaseInstanceId.DeleteInstanceId(); token = FirebaseInstanceId.GetInstance(firebaseApp)?.GetToken(senderId, "FCM"); } } catch { } return(token); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Bootstrap.Begin(() => new DeviceInstallationService()); if (DeviceInstallationService.NotificationsSupported) { FirebaseInstanceId.GetInstance(Firebase.FirebaseApp.Instance) .GetInstanceId() .AddOnSuccessListener(this); } Xamarin.Essentials.Platform.Init(this, savedInstanceState); Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); CreateNotificationChannel(); if (!ShortcutBadger.IsBadgeCounterSupported(this)) { Console.WriteLine("Pay attention: badge counter not supported"); } }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); if (PlayServicesAvailable) { FirebaseInstanceId.GetInstance(Firebase.FirebaseApp.Instance) .GetInstanceId() .AddOnSuccessListener(this); } Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Bootstrap.Begin(() => new DeviceInstallationService( () => PushNotificationFirebaseMessagingService.Token, () => PlayServicesAvailable, () => GetPlayServicesError())); LoadApplication(new App()); ProcessNotificationActions(Intent); }
public void Initialize() { try { if (!this.IsPlayServicesAvailable()) { return; } FirebaseApp.InitializeApp(Application.get_Context()); this.Log("Firebase InstanceID token: " + FirebaseInstanceId.get_Instance().get_Token()); } catch (Exception ex) { this.Log(ex.ToString()); CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, nameof(Initialize), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile/eKreta.Mobile.Android/Platform/PushNotification/AndroidPushNotificationHandler.cs", 51); } }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.Window.RequestFeature(WindowFeatures.ActionBar); base.SetTheme(Resource.Style.MainTheme); base.OnCreate(savedInstanceState); Bootstrap.Begin(() => new DeviceInstallationService()); if (DeviceInstallationService.NotificationsSupported) { FirebaseInstanceId.GetInstance(Firebase.FirebaseApp.Instance) .GetInstanceId() .AddOnSuccessListener(this); } if (Intent.Extras != null) { foreach (var key in Intent.Extras.KeySet()) { if (key != null) { var value = Intent.Extras.GetString(key); Log.Debug(TAG, "Key: {0} Value: {1}", key, value); } } } IsPlayServicesAvailable(); CreateNotificationChannel(); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Xamarin.FormsMaps.Init(this, savedInstanceState); LoadApplication(new App()); ProcessNotificationActions(Intent); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "Fcm" layout resource SetContentView(Resource.Layout.Fcm); this.WireUpViews(); btnSubscribe.SetOnClickListener(this); btnLogToken.SetOnClickListener(this); // Setup our firebase options then init FirebaseOptions o = new FirebaseOptions.Builder() .SetApiKey(GetString(Resource.String.ApiKey)) .SetApplicationId(GetString(Resource.String.ApplicationId)) .SetDatabaseUrl(GetString(Resource.String.DatabaseUrl)) .SetGcmSenderId(GetString(Resource.String.SenderId)) .Build(); FirebaseApp fa = FirebaseApp.InitializeApp(this, o); // Get our instance ID mInstanceId = FirebaseInstanceId.GetInstance(fa); }
public App() { InitializeComponent(); config = DependencyService.Get <SystemConfig>(); firebaseInstanceId = DependencyService.Get <FirebaseInstanceId>(); if (!IsUserLoggedIn) { if (config.GetEmailUser() != null && config.GetPassUser() != null) { MainPage = new WaitingPage(); DoAutomaticLogin(); } else { MainPage = new NavigationPage(new Login()); } } else { MainPage = new MainPage(); } }
public void Initialize(MainController ctr) { _controller = ctr; Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived; Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived; FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://familia-39879.firebaseio.com/"); auth = FirebaseAuth.DefaultInstance; ///google Service version update Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; if (dependencyStatus == Firebase.DependencyStatus.Available) { reference = FirebaseDatabase.DefaultInstance.RootReference; FirebaseInstanceId.GetInstanceId(FirebaseApp.DefaultInstance).GetTokenAsync().ContinueWith(tokentask => { if (tokentask.IsCompleted) { string result = tokentask.Result; idToken = result; } }); } else { Debug.Log("error : could not resolve all firebase dependencies"); return; } }); Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived; }
public virtual async void OnTokenRefresh() { await this.Init(); await this._pushNotificationService.UpdateRegistrationsAsync(FirebaseInstanceId.get_Instance().get_Token()); }
public void btnLogToken_Clicked(object sender, EventArgs e) { FirebaseInstanceId firebaseInstanceId = DependencyService.Get <FirebaseInstanceId>(); Debug.WriteLine(firebaseInstanceId.Token); }