Notifications

LAST EDIT Oct 08 2021
These docs are deprecated and will be removed from the site in the near future. Refer to the most up to date version of the iOS UI Component SDK,

Your Project Settings

Copied!

You need to enable Push Notifications capability in your project settings to make it work.

User Device

Copied!

Add a User Device

Copied!

We need to register a user device for push notifications. Add this code to add a device to a user:

Remove a User Device

Copied!

When a user logged out you need to unregister his device before that to avoid sending push notifications to his old device:

Handle Push Notifications

Copied!

Setup push notifications handler in your AppDelegate to navigate a user to your chat screen with a new message.

Testing if Push Notifications are Setup Correctly

Copied!

If you're not sure if you've setup push notifications correctly (eg you don't always receive them, they work unreliably), please follow https://getstream.io/chat/docs/push_ios/?language=swift to setup your Keys, and https://getstream.io/chat/docs/push_devices/?language=swift to add the device id (so it's eligible to receive notifications)

You can follow these steps to make sure your config is correct and working:

  1. Clone our repo for push testing: https://github.com/GetStream/chat-push-test

  2. Configure necessary fields in the iOS push testing app: App ID, App Secret, Server location

  3. Register your APNS certificate for push testing app, following the page: https://getstream.io/chat/docs/push_ios/?language=swift

  4. Run the app on a physical (real) device, grant notification permission, copy the command it outputs (by long tapping on it) and background the app

  5. Install stream-chat-cli: https://github.com/GetStream/stream-cli

  6. Run the command the iOS push testing app outputted in step 4 in your macos terminal

If done correctly, you should not see any errors after running command in step 6, and should correctly receive notification in your device.