pub struct Utils<'a, R: Runtime> { /* private fields */ }Expand description
API of utils.
Implementations§
Source§impl<'a, R: Runtime> AsyncUtils<'a, R>
impl<'a, R: Runtime> AsyncUtils<'a, R>
Sourcepub async fn create_progress_notification(
&self,
icon: ProgressNotificationIcon,
title: Option<&str>,
text: Option<&str>,
sub_text: Option<&str>,
progress: Option<u64>,
progress_max: Option<u64>,
) -> Result<ProgressNotificationGuard<R>>
pub async fn create_progress_notification( &self, icon: ProgressNotificationIcon, title: Option<&str>, text: Option<&str>, sub_text: Option<&str>, progress: Option<u64>, progress_max: Option<u64>, ) -> Result<ProgressNotificationGuard<R>>
Displays a notification indicating progress on status bar.
The returned ProgressNotificationGuard can be used to manage the notification.
- Calling
ProgressNotificationGuard::updatewill update the notification. - Calling
ProgressNotificationGuard::completewill finish the notification as a “success”. - Calling
ProgressNotificationGuard::failwill finish the notification as a “failure”.
By default, ProgressNotificationGuard finishes the notification as a “failure” when dropped.
You can change the drop behavior by using ProgressNotificationGuard::set_drop_behavior_to_complete or ProgressNotificationGuard::set_drop_behavior_to_fail.
§Note
This needs two steps:
-
Declare :
By enabling thenotification_permissionfeature,
you can declare the permissions automatically at build time. -
Runtime request :
By callingUtils::request_notification_permission, you can request the permissions from the user at runtime.
§Support
All Android version.
Sourcepub async fn request_notification_permission(&self) -> Result<bool>
pub async fn request_notification_permission(&self) -> Result<bool>
§Note
To request the permissions, you must declare POST_NOTIFICATIONS in AndroidManifest.xml.
By enabling the notification_permission feature,
the permissions will be declared automatically.