docs.unity3d.com
    Show / Hide Table of Contents

    Struct AndroidNotification

    The AndroidNotification is used schedule a local notification, which includes the content of the notification.

    Namespace: Unity.Notifications.Android
    Syntax
    public struct AndroidNotification

    Constructors

    AndroidNotification(String, String, DateTime)

    Create a notification struct with all optional fields set to default values.

    Declaration
    public AndroidNotification(string title, string text, DateTime fireTime)
    Parameters
    Type Name Description
    String title

    Notification title

    String text

    Text to show on notification

    DateTime fireTime

    Date and time when to show, can be DateTime.Now to show right away

    AndroidNotification(String, String, DateTime, TimeSpan)

    Create a repeatable notification struct with all optional fields set to default values.

    Declaration
    public AndroidNotification(string title, string text, DateTime fireTime, TimeSpan repeatInterval)
    Parameters
    Type Name Description
    String title

    Notification title

    String text

    Text to show on notification

    DateTime fireTime

    Date and time when to show, can be DateTime.Now to show right away

    TimeSpan repeatInterval

    Makes notification repeatable with this time interval

    Remarks

    There is a minimum period of 1 minute for repeating notifications.

    AndroidNotification(String, String, DateTime, TimeSpan, String)

    Create a notification struct with a custom small icon and all optional fields set to default values.

    Declaration
    public AndroidNotification(string title, string text, DateTime fireTime, TimeSpan repeatInterval, string smallIcon)
    Parameters
    Type Name Description
    String title

    Notification title

    String text

    Text to show on notification

    DateTime fireTime

    Date and time when to show, can be DateTime.Now to show right away

    TimeSpan repeatInterval

    Makes notification repeatable with this time interval

    String smallIcon

    Name of the small icon to be shown on notification

    Properties

    Color

    Accent color to be applied by the standard style templates when presenting this notification. The template design constructs a colorful header image by overlaying the icon image (stenciled in white) atop a field of this color. Alpha components are ignored.

    Declaration
    public Color? Color { get; set; }
    Property Value
    Type Description
    Nullable<Color>

    CustomTimestamp

    Set this to show custom date instead of the notification's "FireTime" as the notification's timestamp'.

    Declaration
    public DateTime CustomTimestamp { get; set; }
    Property Value
    Type Description
    DateTime

    FireTime

    The date and time when the notification should be delivered.

    Declaration
    public DateTime FireTime { readonly get; set; }
    Property Value
    Type Description
    DateTime

    Group

    Set this property for the notification to be made part of a group of notifications sharing the same key. Grouped notifications may display in a cluster or stack on devices which support such rendering. Only available on Android 7.0 (API level 24) and above.

    Declaration
    public string Group { readonly get; set; }
    Property Value
    Type Description
    String

    GroupAlertBehaviour

    Sets the group alert behavior for this notification. Set this property to mute this notification if alerts for this notification's group should be handled by a different notification. This is only applicable for notifications that belong to a group. This must be set on all notifications you want to mute. Only available on Android 8.0 (API level 26) and above.

    Declaration
    public GroupAlertBehaviours GroupAlertBehaviour { readonly get; set; }
    Property Value
    Type Description
    GroupAlertBehaviours

    GroupSummary

    Set this notification to be the group summary for a group of notifications. Requires the 'Group' property to also be set. Grouped notifications may display in a cluster or stack on devices which support such rendering. Only available on Android 7.0 (API level 24) and above.

    Declaration
    public bool GroupSummary { readonly get; set; }
    Property Value
    Type Description
    Boolean

    IntentData

    Use this to save arbitrary string data related to the notification.

    Declaration
    public string IntentData { readonly get; set; }
    Property Value
    Type Description
    String

    LargeIcon

    Notification large icon. Add a large icon to the notification content view. This image will be shown on the left of the notification view in place of the small icon (which will be placed in a small badge atop the large icon). The icon PNG file has to be placed in the /Assets/Plugins/Android/res/drawable folder and it's name has to be specified without the extension.

    Declaration
    public string LargeIcon { readonly get; set; }
    Property Value
    Type Description
    String

    Number

    Sets the number of items this notification represents. Is displayed as a badge count on the notification icon if the launcher supports this behavior.

    Declaration
    public int Number { readonly get; set; }
    Property Value
    Type Description
    Int32

    RepeatInterval

    The notification will be be repeated on every specified time interval. Do not set for one time notifications.

    Declaration
    public TimeSpan? RepeatInterval { get; set; }
    Property Value
    Type Description
    Nullable<TimeSpan>

    ShouldAutoCancel

    This notification will automatically be dismissed when the user touches it. By default this behavior is turned off.

    Declaration
    public bool ShouldAutoCancel { readonly get; set; }
    Property Value
    Type Description
    Boolean

    ShowInForeground

    Set this notification to be shown when app is in the foreground (default: true).

    Declaration
    public bool ShowInForeground { get; set; }
    Property Value
    Type Description
    Boolean

    ShowTimestamp

    Enable it to show a timestamp on the notification when it's delivered, unless the "CustomTimestamp" property is set "FireTime" will be shown.

    Declaration
    public bool ShowTimestamp { readonly get; set; }
    Property Value
    Type Description
    Boolean

    SmallIcon

    Notification small icon. It will be used to represent the notification in the status bar and content view (unless overridden there by a large icon) The icon PNG file has to be placed in the /Assets/Plugins/Android/res/drawable folder and it's name has to be specified without the extension.

    Declaration
    public string SmallIcon { readonly get; set; }
    Property Value
    Type Description
    String

    SortKey

    The sort key will be used to order this notification among other notifications from the same package. Notifications will be sorted lexicographically using this value.

    Declaration
    public string SortKey { readonly get; set; }
    Property Value
    Type Description
    String

    Style

    Apply a custom style to the notification. Currently only BigPicture and BigText styles are supported.

    Declaration
    public NotificationStyle Style { readonly get; set; }
    Property Value
    Type Description
    NotificationStyle

    Text

    Notification body. Set the second line of text in the notification.

    Declaration
    public string Text { readonly get; set; }
    Property Value
    Type Description
    String

    Title

    Notification title. Set the first line of text in the notification.

    Declaration
    public string Title { readonly get; set; }
    Property Value
    Type Description
    String

    UsesStopwatch

    Show the notification time field as a stopwatch instead of a timestamp.

    Declaration
    public bool UsesStopwatch { readonly get; set; }
    Property Value
    Type Description
    Boolean
    In This Article
    • Constructors
      • AndroidNotification(String, String, DateTime)
      • AndroidNotification(String, String, DateTime, TimeSpan)
      • AndroidNotification(String, String, DateTime, TimeSpan, String)
    • Properties
      • Color
      • CustomTimestamp
      • FireTime
      • Group
      • GroupAlertBehaviour
      • GroupSummary
      • IntentData
      • LargeIcon
      • Number
      • RepeatInterval
      • ShouldAutoCancel
      • ShowInForeground
      • ShowTimestamp
      • SmallIcon
      • SortKey
      • Style
      • Text
      • Title
      • UsesStopwatch
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023