Push Notifications

Enabling user notifications and receiving notifications when the app is closed.

Enabling User Notifications

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.

Enabling or disabling user notifications is a preference often best left up to the user, so by default, user notifications are disabled. However they are easily enabled with a single call to the PushManager instance.

Enable user notifications (Android Native Bindings)
UAirship.Shared().PushManager.UserNotificationsEnabled = true;
Enable user notifications (iOS Native Bindings)
UAirship.Push().UserPushNotificationsEnabled = true;

Enable user notifications (.Net Standard Library)
Airship.Instance.UserNotificationsEnabled = true;

Receiving Notifications When The App Is Closed

iOS and Android both try to protect the user from malicious apps by halting notification display when the app has been actively terminated by the user. The rationale for this is that if a user consciously closes an app, instead of merely backgrounding or minimizing it, it would be a bad user experience to continue to receive notifications, which may be unwanted.

On Android especially, this behavior is quite easy to accidentally trigger by swiping an app away or killing the app with a third-party task manager application. Xamarin also makes this even easier to trigger by forcefully closing the app whenever it detaches from the debugger in Visual Studio.

If you are testing push and have concerns as to whether notifications are being delivered when the app is closed, the best testing procedure is to launch the app manually on your test device and back out to the home screen, making sure not to swipe it away or otherwise forcefully quit the app. Most cases where push appears to be broken when the app is closed can be traced to this quirk of behavior.