Package 

Interface INotificationsManager

    • Method Detail

      • requestPermission

         abstract Boolean requestPermission(Boolean fallbackToSettings)

        Prompt the user for permission to push notifications. This will display the native OS prompt to request push notification permission. If the user enables, a push subscription to this device will be automatically added to the user.

        Be aware of best practices regarding asking permissions on Android: Requesting Permissions | Android Developers (https://developer.android.com/guide/topics/permissions/requesting.html)

        Parameters:
        fallbackToSettings - Whether to direct the user to this app's settings to drive enabling of notifications, when the in-app prompting is not possible.
      • removeNotification

         abstract Unit removeNotification(Integer id)

        Cancels a single OneSignal notification based on its Android notification integer ID. Use instead of Android's android.app.NotificationManager.cancel, otherwise the notification will be restored when your app is restarted.

        Parameters:
        id - The android ID of the notification to be removed.
      • removeGroupedNotifications

         abstract Unit removeGroupedNotifications(String group)

        Cancels a group of OneSignal notifications with the provided group key. Grouping notifications is a OneSignal concept, there is no android.app.NotificationManager equivalent.

        Parameters:
        group - The group key which all notifications fall under will be removed.
      • addPermissionObserver

         abstract Unit addPermissionObserver(IPermissionObserver observer)

        Add a permission observer that will run when the notification permission changes. This happens when the user enables or disables notifications for your app either within the app or from the system settings outside of your app. Disable detection is supported on Android 4.4+.

        Keep a reference - Make sure to hold a reference to your handler at the class level, otherwise it may not fire.

        Leak Safe - OneSignal holds a weak reference to your handler so it's guaranteed not to leak your Activity.

        Parameters:
        observer - the instance of IPermissionObserver that you want to process the permission changes within
      • addClickListener

         abstract Unit addClickListener(INotificationClickListener listener)

        Add a click listener that will run whenever a notification is clicked on by the user.

        Parameters:
        listener - The listener that is to be called when the event occurs.