تخطَّ إلى المحتوى
العربية

Notifications

هذا المحتوى غير متوفر بلغتك بعد.

The Notifications panel sends a push notification to your app on an iOS Simulator or Android emulator. On Android, it can also deliver it through your app’s notification handling when the FCM broadcast can’t reach the app.

Pick a starting payload from Choose a template…. It lists the Templates for the connected app’s platform, then your Saved presets. When an app on the other platform connects, the editor switches to its preset with the same name, or to that platform’s default template.

iOS templates:

  • Custom data (the default). Your custom data goes under the top-level body key, which expo-notifications reads as the notification’s data.
  • Basic alert, Alert with subtitle, Badge only, Alert with sound, Silent background push and Actionable (category).
  • Rich (image). The image only shows if your app has a Notification Service Extension that adds it.

Android templates:

  • Android: custom data (the default).
  • Android: basic notification and Android: with channel.
  • Android: with image. The image shows when the notification is sent over adb (see Sending over adb below), but not when it’s delivered through expoNotifications.
  • Android: data-only (expo), which sets data.title and data.message, the keys expo-notifications shows for a payload with only data.

The payload is edited as JSON. Format JSON (Shift+Option+F, or Shift+Alt+F on Windows and Linux) tidies it. While the payload is invalid, the problem is shown under the editor and you can’t send or save it:

  • iOS: the payload needs an aps object.
  • Android: the payload can only have notification, data and android keys, and needs a notification or data object. Every value in notification and data must be a string, and so must android.notification.channel_id.
  • Either platform: the payload can be at most 4096 bytes.

Click Send to device. It’s disabled until an app is connected. Hover it to see which app and device the notification goes to.

  • iOS: the notification is pushed to the app on the booted iOS Simulator.
  • Android: the notification is sent to the app’s Firebase Cloud Messaging receiver over adb. If that fails and your app passes a handler to notifications, it’s delivered through your app instead.

Click Save as preset, enter a Preset name and click Save. Presets are saved per platform. Saving with the name of an existing preset, in any case, replaces it.

Select a preset and click Delete preset to delete it. The editor, your presets and the selected one are kept when you close the app.

  • iOS notifications can only go to an iOS Simulator, not a physical device.
  • “Couldn’t run xcrun.”: install Xcode and its command line tools.
  • “No iOS Simulator is booted.”: boot one, with your app running on it.
  • “Couldn’t run adb.”: install the Android platform tools.
  • “The device hasn’t authorised this computer.”: accept the USB debugging prompt on the device.
  • “This emulator image doesn’t allow root, which the FCM broadcast needs.” or “… has no FCM receiver to take the broadcast.”: see Sending over adb, or pass a handler to notifications to deliver through your app.
  • The panel doesn’t keep a history of sent notifications.