Skip to content

User#

flet_onesignal.user.OneSignalUser #

OneSignal User namespace.

Provides methods for managing user identity, tags, aliases, email, SMS, and language.

Functions#

add_alias async #

add_alias(label: str, id: str) -> None

Add a single alias to the current user.

Parameters:

Name Type Description Default
label str

The alias label.

required
id str

The alias ID.

required

add_aliases async #

add_aliases(aliases: dict[str, str]) -> None

Add multiple aliases to the current user.

Parameters:

Name Type Description Default
aliases dict[str, str]

A dictionary of alias label-ID pairs.

required

add_email async #

add_email(email: str) -> None

Add an email address to the current user.

Parameters:

Name Type Description Default
email str

The email address to add.

required

add_sms async #

add_sms(phone: str) -> None

Add an SMS number to the current user.

Parameters:

Name Type Description Default
phone str

The phone number to add (E.164 format recommended).

required

add_tag async #

add_tag(key: str, value: str) -> None

Add a single tag to the current user.

Parameters:

Name Type Description Default
key str

The tag key.

required
value str

The tag value.

required

add_tags async #

add_tags(tags: dict[str, str]) -> None

Add multiple tags to the current user.

Parameters:

Name Type Description Default
tags dict[str, str]

A dictionary of tag key-value pairs.

required

get_external_id async #

get_external_id(timeout: float = 25) -> Optional[str]

Get the external ID for the current user.

Returns:

Type Description
Optional[str]

The external ID, or None if not set.

get_onesignal_id async #

get_onesignal_id(timeout: float = 25) -> Optional[str]

Get the OneSignal ID for the current user.

Returns:

Type Description
Optional[str]

The OneSignal ID, or None if not available.

get_push_subscription_id async #

get_push_subscription_id(
    timeout: float = 25,
) -> Optional[str]

Get the push subscription ID.

Returns:

Type Description
Optional[str]

The push subscription ID, or None if not available.

get_push_subscription_token async #

get_push_subscription_token(
    timeout: float = 25,
) -> Optional[str]

Get the push subscription token.

Returns:

Type Description
Optional[str]

The push subscription token, or None if not available.

get_tags async #

get_tags(timeout: float = 25) -> dict[str, str]

Get all tags for the current user.

Returns:

Type Description
dict[str, str]

A dictionary of tag key-value pairs.

is_push_opted_in async #

is_push_opted_in(timeout: float = 25) -> bool

Check if the user is opted in to push notifications.

Returns:

Type Description
bool

True if opted in, False otherwise.

opt_in_push async #

opt_in_push() -> None

Opt the user in to push notifications.

Call this to receive push notifications on the device or to resume receiving notifications after calling opt_out_push().

opt_out_push async #

opt_out_push() -> None

Opt the user out of push notifications.

The user will stop receiving push notifications on the current device.

remove_alias async #

remove_alias(label: str) -> None

Remove a single alias from the current user.

Parameters:

Name Type Description Default
label str

The alias label to remove.

required

remove_aliases async #

remove_aliases(labels: list[str]) -> None

Remove multiple aliases from the current user.

Parameters:

Name Type Description Default
labels list[str]

A list of alias labels to remove.

required

remove_email async #

remove_email(email: str) -> None

Remove an email address from the current user.

Parameters:

Name Type Description Default
email str

The email address to remove.

required

remove_sms async #

remove_sms(phone: str) -> None

Remove an SMS number from the current user.

Parameters:

Name Type Description Default
phone str

The phone number to remove.

required

remove_tag async #

remove_tag(key: str) -> None

Remove a single tag from the current user.

Parameters:

Name Type Description Default
key str

The tag key to remove.

required

remove_tags async #

remove_tags(keys: list[str]) -> None

Remove multiple tags from the current user.

Parameters:

Name Type Description Default
keys list[str]

A list of tag keys to remove.

required

set_language async #

set_language(language_code: str) -> None

Set the language for the current user.

This also applies to email and SMS subscriptions.

Parameters:

Name Type Description Default
language_code str

The ISO 639-1 language code (e.g., "en", "pt", "es").

required