> ## Documentation Index
> Fetch the complete documentation index at: https://docs.playtolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Push Notifications

> Cross-platform push notifications with PlaytoliaNotifications

Playtolia Push uses Firebase Cloud Messaging (FCM) to send notifications across Android and iOS — transaction confirmations, social updates (friend requests, party invites), and marketing messages.

### Requirements

* Firebase Unity SDK with Cloud Messaging configured
  See [Firebase FCM setup for Unity](https://firebase.google.com/docs/cloud-messaging/get-started?platform=unity)

### Enable Playtolia Push

Navigate to **Edit → Project Settings → Playtolia Settings** and enable Push Notifications. Changes take effect with the next build.

### Notification permission

Android 13+ and iOS require explicit permission. Choose a strategy in Playtolia Settings:

| Strategy                  | When permission is requested         |
| ------------------------- | ------------------------------------ |
| **During Initialization** | On first app launch                  |
| **After Login**           | Immediately after the player logs in |
| **Custom**                | You call the request manually        |

<Info>It's generally better UX to ask for notification permission after the player has experienced some value — after a tutorial or first session, not immediately on launch.</Info>

### Requesting permission manually (Custom strategy)

```c# theme={null}
PlaytoliaNotifications.RequestPushPermission();
```

### Checking permission status

```c# theme={null}
string permission = PlaytoliaNotifications.GetPermission();
// Returns: "Granted", "DeniedAlways", or "NotGranted"
```

### Registering a push token

After Firebase initializes and provides a token, pass it to Playtolia so the backend can target this device:

```c# theme={null}
PlaytoliaNotifications.RegisterPushToken(firebaseToken);
```

### Opening notification settings

Sends the user to the OS notification settings for your app — useful when permission was previously denied:

```c# theme={null}
PlaytoliaNotifications.OpenNotificationSettings();
```

### Reading state

```c# theme={null}
var state = PlaytoliaNotifications.GetState();
// state.Permission  — current permission string
// state.Preferences — Dictionary<string, bool> of notification categories
```

### Listening to changes

```c# theme={null}
void Start()    => PlaytoliaNotifications.AddListener(OnNotificationsChanged);
void OnDestroy() => PlaytoliaNotifications.RemoveListener(OnNotificationsChanged);

void OnNotificationsChanged()
{
    var state = PlaytoliaNotifications.GetState();
    // update UI
}
```

<CardGroup cols={2}>
  <Card title="SDK Reference" icon="code" href="/sdk-reference/notifications">PlaytoliaNotifications reference</Card>
  <Card title="Promotions" icon="star" href="/for-unity/promotions">App review prompts</Card>
</CardGroup>
