Maybe No One Here@brunobr0wn my brother I work with flet_onesignal
I want know how to send notification to a one person on 2 not everyone
U use this and it not work
Hey bro! There’s an important architectural detail about OneSignal here. 😊
1. The flet-onesignal is a client SDK; it DOES NOT send notifications
All the package does within the app is:
- request permission,
- identify the user (login),
- receive notifications,
- manage tags, aliases, and opt-in/opt-out settings.
The notification is always sent by the OneSignal server; you trigger the sending by calling the REST API (https://api.onesignal.com/notifications) from your own backend or through the web platform (https://dashboard.onesignal.com/apps).
So the onesignal.login(...) you circled in the image is correct: it just binds that
device to your external_id (in your case, the delivery worker's username). It doesn't
fire any notification by itself — it only sets up the "address" so you can target that user later.
2. How to target 1 or 2 specific users
Once each user has called login(external_id) in the app, you send the notification like this (from your backend or any Python script):
import httpx # or requests
ONESIGNAL_APP_ID = "your-app-id"
ONESIGNAL_REST_API_KEY = "your-REST-API-KEY"
async def send_to_users(external_ids: list[str], title: str, message: str):
payload = {
"app_id": ONESIGNAL_APP_ID,
"target_channel": "push",
"include_aliases": {
"external_id": external_ids # e.g. ["john", "mary"]
},
"headings": {"en": title},
"contents": {"en": message},
}
async with httpx.AsyncClient() as client:
r = await client.post(
"https://api.onesignal.com/notifications",
headers={
"Authorization": f"Key {ONESIGNAL_REST_API_KEY}",
"Content-Type": "application/json",
},
json=payload,
)
print(r.status_code, r.json())
# To 1 person:
await send_to_users(["john_driver"], "New order", "There's a new order for you!")