Skip to main content
Version: 14 Oct 2024

ml_system_notification_manager.h

Functions

Name
MLResultMLSystemNotificationManagerCreate(MLHandle * out_handle)
Creates a System Notification Manager handle.
MLResultMLSystemNotificationManagerDestroy(MLHandle handle)
Destroys a System Notification Manager handle.
MLResultMLSystemNotificationManagerSetNotifications(MLHandle handle, bool suppress)
Request suppression/unsuppression of system notifications.

Functions Documentation

MLSystemNotificationManagerCreate

MLResult MLSystemNotificationManagerCreate(
MLHandle * out_handle
)

Creates a System Notification Manager handle.

Parameters

MLHandle *out_handleThe handle to be created.

Returns

MLResultMLResult_InvalidParamFailed due to an invalid parameter.
MLResultMLResult_OkSystem Notification Manager handle was successfully created.
MLResultMLResult_PermissionDeniedNecessary permission is missing.
MLResultMLResult_UnspecifiedFailureSystem Notification Manager handle failed to be created.

Required Permissions:

  • com.magicleap.permission.SYSTEM_NOTIFICATION (protection level: normal)

Multiple calls to this API method from the same applicaiton will return the same handle. The handle is valid for the lifecycle of the application.

API Level:

  • 24

MLSystemNotificationManagerDestroy

MLResult MLSystemNotificationManagerDestroy(
MLHandle handle
)

Destroys a System Notification Manager handle.

Parameters

MLHandlehandleThe handle to be destroyed.

Returns

MLResultMLResult_InvalidParamThe handle passed in was not valid.
MLResultMLResult_OkSystem Notification Manager handle was successfully destroyed.

Required Permissions:

  • None

API Level:

  • 24

MLSystemNotificationManagerSetNotifications

MLResult MLSystemNotificationManagerSetNotifications(
MLHandle handle,
bool suppress
)

Request suppression/unsuppression of system notifications.

Parameters

MLHandlehandleHandle to System Notification Manager.
boolsuppressTrue to suppress all notifications, false to unsuppress all notifications.

Returns

MLResultMLResult_IncompatibleSKUFailed due to feature not being supported on current device version.
MLResultMLResult_InvalidParamThe handle passed in was not valid.
MLResultMLResult_OkAll system notifications were successfully suppressed/unsuppressed.
MLResultMLResult_UnspecifiedFailureSuppression/Unsuppression of system notifications failed.

Required Permissions:

  • None

Requests the system to unsuppress/suppress all notifications. This includes notifications, dialogs and alarms from being displayed. Once suppressed, notifications remain suppressed even if the application requesting suppression loses focus (ie: if the user navigates away from the application).

If the calling app is closed for any reason (ie. closed by user action, voice command, terminal command, or crashed) before notifications were unsuppressed the System Notification Manager will automatically unsuppress all notficiations (unless another application was currently suppressing notifications).

API Level:

  • 24

Source code

// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2023 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%

#pragma once

#include "ml_api.h"
#include "ml_types.h"

ML_EXTERN_C_BEGIN

ML_API MLResult ML_CALL MLSystemNotificationManagerCreate(MLHandle* out_handle);

ML_API MLResult ML_CALL MLSystemNotificationManagerDestroy(MLHandle handle);

ML_API MLResult ML_CALL MLSystemNotificationManagerSetNotifications(MLHandle handle, bool suppress);

ML_EXTERN_C_END