Push Notifications for the .NET Package
How to configure your application to receive and respond to notifications.
Enable User Notifications
Enabling userNotificationsEnabled will prompt the user for permission to send notifications. To increase the likelihood that the user will accept, you should avoid prompting the user for permission immediately, and instead wait for a more appropriate time in the app.
The Airship SDK makes a distinction between user notifications, which can be seen by the user, and other forms of push that allow you to send data to your app silently, or in the background. Enabling or disabling user notifications is a preference often best left up to the user, so by default, user notifications are disabled.
Airship.Instance.UserNotificationsEnabled = trueFor apps that target Android 13 (API 33) and above, enabling user notifications will display a runtime permission prompt to allow notifications to be sent.
To increase the likelihood that the user will accept, you should avoid prompting the user for permission immediately on app startup, and instead wait for a more appropriate time to prompt for notification permission.
Handle Notification Events
The Airship SDK provides several callbacks for when a push is received or a notification is interacted with. Apps can use these callbacks to do custom push processing. Registering for a callback is optional, the SDK will automatically launch the application without the need to set a callback.
Notification callbacks are not supported in Airship.NET library. Use native binding methods instead.
Silent Notifications
Silent notifications are push messages that do not present a notification to the user. These are typically used to briefly wake the app from a background state to perform processing tasks or fetch remote content.
We recommend that you thoroughly test your implementation to confirm that silent notifications do not generate any device notifications.
For Android, all push messages are delivered in the background, but default Airship will treat messages without an alert as silent. For iOS, set the content_available property to true in the iOS override object.
Pushes sent with the content_available property (iOS) or without an alert (Android) do not have guaranteed delivery. Factors affecting delivery include battery life, whether the device is connected to WiFi, and the number of silent pushes sent within a recent time period. These metrics are determined solely by iOS/Android and APNs/FCM. Therefore, this feature is best used for supplementing the regular behavior of the app rather than providing critical functionality. For instance, an app could use a silent push to pre-fetch new data ahead of time in order to reduce load times when the app is later launched by the user.
iOS Notification Options
iOS notification options, badges, and quiet time are not supported in Airship.NET library. Use native binding methods instead.
Categories