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.
false | NotificationsPluginConfig اختياري| الخيار | النوع | الافتراضي | الوصف |
|---|---|---|---|
expoNotifications | ExpoNotificationsLike | — | وحدة expo-notifications. يعرض خيار الإرسال إلى الجهاز في تطبيق سطح المكتب إشعارًا عبر معالجها عندما يتعذر على FCM الوصول إلى الجهاز. |
onRemoteMessage | (message: RemoteMessageLike) => unknown | — | معالجك لرسائل FCM، مثل الدالة التي تمررها إلى messaging().onMessage. تكون له الأولوية على expoNotifications عند تعيين الاثنين. |
Pass the handler that shows notifications in your app:
Pass the expo-notifications module. The notification is shown with
scheduleNotificationAsync, using the payload’s notification title and body. A payload with
only data uses data.title and data.message. The image isn’t shown.
import { init } from '@xerlock/client';import * as Notifications from 'expo-notifications';
init({ notifications: { expoNotifications: Notifications },});Pass the handler you use for foreground FCM messages, such as the one you give to
messaging().onMessage. It receives an FCM-style message whose from is xerlock. No system
notification is shown: the message only reaches your handler, as an FCM message does while your
app is in the foreground.
import { init } from '@xerlock/client';
import { showNotification } from './show-notification';
init({ notifications: { onRemoteMessage: (message) => showNotification(message.notification), },});If you pass both, onRemoteMessage is used.
Shapes
Section titled “Shapes”| العضو | الوصف |
|---|---|
scheduleNotificationAsync(request: { content: { title?: string; body?: string; data?: Record<string, unknown>; sound?: boolean | string; }; trigger: null | { channelId: string }; }): Promise<string> | Shows a notification through the app's notification handler. trigger: null shows it immediately. |
| العضو | الوصف |
|---|---|
messageId: string | Always starts with xerlock- for a message sent from the desktop app. |
from: string | The sender id. Always xerlock for a message sent from the desktop app. |
sentTime: number | When the message was sent, in milliseconds since the epoch. |
ttl: number | Seconds the message may live. |
notification?: { title?: string; body?: string; android?: { channelId?: string; imageUrl?: string }; } | The notification part, if the payload had one. |
data?: Record<string, string> | The custom data, with string values. |
Turning it off
Section titled “Turning it off”Leave out notifications, or pass false. Sending to an iOS Simulator, and over adb on Android,
still works without it.
Limits and Troubleshooting
Section titled “Limits and Troubleshooting”- “Add
notificationsto the Xerlock client config to deliver through the app instead.”: the FCM broadcast failed and no handler is set. PassexpoNotificationsoronRemoteMessage. - “The app has no handler for incoming notifications.”: pass
expoNotificationsoronRemoteMessage. - “The app’s notification handler threw an error.”: the toast shows the error your handler threw.