NotificationOpened not firing
See original GitHub issueIf you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.
Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.
Bug Information
Version Number of Plugin: 2.3.0 Device Tested On: Simulator Tested On: Emulator Android 8.1 27 Version of VS: 2017 Enterprise Version of Xamarin: 3.0.0.561731 Versions of other things you are using:
Steps to reproduce the Behavior
Create a notification and subscribe to it, then setup a OnNotificationReceived event handler
Expected Behavior
When clicking on the buttons (Reply , Forward) it should trigger the above event
Actual Behavior
App Launches, no event triggered.
Code snippet
MainApplication.cs
public override void OnCreate()
{
base.OnCreate();
//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";
}
//If debug you should reset the token each time.
#if DEBUG
FirebasePushNotificationManager.Initialize(this,
new NotificationUserCategory[]
{
new NotificationUserCategory("message",new List<NotificationUserAction> {
new NotificationUserAction("Reply","Reply", NotificationActionType.Foreground),
new NotificationUserAction("Forward","Forward", NotificationActionType.Foreground)
})
},true);
#else
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.Subscribe("general");
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
//Toast.MakeText(ApplicationContext, "Hello", ToastLength.Long).Show();
};
CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
{
//Fired;
};
MainActivity.cs
[Activity(Label = "Notifications2", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
FirebasePushNotificationManager.ProcessIntent(this,Intent);
}
}
Screenshots
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Perfect thank you!