-
Notifications
You must be signed in to change notification settings - Fork 176
Never got the Token & Never received the Notification sent from FCM Console #150
Description
I got the Notifications the first time I have implemented this package three days ago (received couple of notifications), but from the next day I haven't got any notifications and the Token is always empty in debug mode. I have tried in Release mode also but i'm not getting Notifications. I have tried all possible troubleshooting methods, re-installed Packages, clean and rebuild, re-installing the application etc., but no success. I am not getting any build/runtime errors, and application is working fine, but just the notifications are not receiving, either in the background or in the foreground.
BTW, I am trying to send sample messages from FCM Console, with and without custom data.
And I believe all the FCM related settings are proper in the application.
I am running Xamarin.Forms with only Android and PCL projects.
Below is the PCL App.xaml.cs file OnStart() method
protected override void OnStart()
{
CrossFirebasePushNotification.Current.Subscribe("general");
CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) =>
{
System.Diagnostics.Debug.WriteLine($"TOKEN REC: {p.Token}");
};
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Received");
};
CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Opened");
};
CrossFirebasePushNotification.Current.OnNotificationDeleted += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Dismissed");
};
}
Below is the MainApplication.cs from Android Platform Project
public override void OnCreate()
{
base.OnCreate();
RegisterActivityLifecycleCallbacks(this);
#if DEBUG
FirebasePushNotificationManager.Initialize(this, true);
#else
FirebasePushNotificationManager.Initialize(this, false);
#endif
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("NOTIFICATION RECEIVED", p.Data);
};
if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
FirebasePushNotificationManager.DefaultNotificationChannelId = "DefaultChannel";
FirebasePushNotificationManager.DefaultNotificationChannelName = "General";
}
}
I am using below IDE & Packages.
My MainActivity.cs
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App(new AndroidInitializer()));
FirebasePushNotificationManager.ProcessIntent(this, Intent);
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
FirebasePushNotificationManager.ProcessIntent(this, intent);
}
Version Number of Plugin: 2.3.0
Device Tested On: OnePlus 5T with Android 8.1
Version of VS: VS 2017 15.6.4
Version of Xamarin.Forms: 3.0.0.550146