Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification received event #116

Merged
merged 5 commits into from
Sep 28, 2020

Conversation

GiampaoloGabba
Copy link
Contributor

@GiampaoloGabba GiampaoloGabba commented Sep 26, 2020

Add a new event fired when a local notification is Notified.

Fixes #105

While using this plugin i missed the functionality (expecially on Android) to being able to display a custom banner when a notification is received and the app is in foreground.

Push notifications plugins are exposing the NotificationReceived event, so why not add it to local notifications? 😄

This PR adds the new event NotificationReceived with the following args:

/// <summary>
/// Returning event when a notification is received.
/// On iOS this event is fired only when the app is in foreground
/// </summary>
public class NotificationReceivedEventArgs : EventArgs
{
    /// <summary>
    /// Returning title when a notification is received.
    /// </summary>
    public string Title { get; internal set; }

    /// <summary>
    /// Returning details when a notification is received.
    /// </summary>
    public string Description { get; internal set; } = string.Empty;

    /// <summary>
    /// Returning data when a notification is received.
    /// </summary>
    public string Data { get; internal set; }
}

Notes for iOS

Due to iOS limitations, this event will be fired only when the app is in foregound

The following property has been added to give us the option to create a custom notification alert when a notification is received:

/// <summary>
/// NotificationRequest for iOS
/// </summary>
public class iOSOptions
{
    /// <summary>
    /// Setting this flag will prevent iOS from displaying the default banner when a Notification is received in foreground
    /// Default is false
    /// </summary>
    public bool HideForegroundAlert { get; set; }
}

README and Main demos are updated aswell

thudugala
thudugala approved these changes Sep 28, 2020
@thudugala thudugala merged commit e103bb4 into thudugala:master Sep 28, 2020
@thudugala
Copy link
Owner

Published with v5.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OnNotificationReceived event
2 participants