Package 

Interface INotificationWillDisplayEvent


  • 
    public interface INotificationWillDisplayEvent
    
                        

    The event passed into INotificationLifecycleListener.onWillDisplay, it provides access to the notification to be displayed and the ability to change whether that notification will be displayed to the user.

    The notification provided in this event is an IDisplayableNotification, which allows the notification to be displayed outside of the event callback. To display the notification outside of the event callback (for instance, if you need to perform asynchronous processing to determine whether to display the notification).

    object : INotificationLifecycleListener {
      fun willDisplay(event: INotificationWillDisplayEvent) {
        event.preventDefault()
        thread {
          // do something async
    
          // optionally, display the notification manually
          event.notification.display()
        }
      }
    }
    • Method Summary

      Modifier and Type Method Description
      abstract Unit preventDefault() Call this to prevent OneSignal from displaying the notification automatically.
      abstract Unit preventDefault(Boolean discard) Call this to prevent OneSignal from displaying the notification automatically.
      abstract IDisplayableNotification getNotification() The notification that has been received.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • preventDefault

         abstract Unit preventDefault()

        Call this to prevent OneSignal from displaying the notification automatically. The caller still has the option to display the notification by calling notification.display().

      • preventDefault

         abstract Unit preventDefault(Boolean discard)

        Call this to prevent OneSignal from displaying the notification automatically. This method can be called up to two times with false and then true, if processing time is needed. Typically this is only possible within a short time-frame (~30 seconds) after the notification is received on the device.

        Parameters:
        discard - an preventDefault set to true to dismiss the notification with no possibility of displaying it in the future.