Notifications & Events
Control trips, timing and events for Capacitor 0.2.x.
Change or cancel a trip
Stay22.setTravelContext(...) forwards the fields you supply to the native SDK. Omitted non-empty destination, hotel, coordinate and date values can remain from earlier calls. Clear before an unrelated trip or a reset search:
await Stay22.clearTravelContext();
await Stay22.setTravelContext({ address: 'Paris, France' });A context update can replace a pending notification rather than adding a second notification. Updating only adults or children is ignored by the native context signature; clear and resend the complete trip to change only guest counts.
Stay22.setEnabled({ enabled: false }) and Stay22.clearTravelContext() cancel pending work, including an in-progress scheduling decision. Apply the current consent choice whenever it changes.
Timing and appearance
Normal scheduling waits for the app to leave the foreground and follows the account's delay and frequency limits. The local home-city check, cooldown and server decision can prevent an offer. The operating system may display it later than requested.
The JavaScript plugin does not expose notification-appearance configuration. It uses the wrapped native SDK's default copy. From plugin 0.2.0, built-in English or French text follows the device language at scheduling time.
Events
const listener = await Stay22.addListener('stay22Event', (event) => {
console.log(event.type, event.description);
if (event.type === 'notificationClicked') {
console.log(event.url);
}
});Call await listener.remove() when the subscription is no longer needed. Event types include locationUpdated, notificationScheduled, notificationShown, notificationClicked, notificationBlocked, notificationSkipped, notificationCancelled, enabledChanged and travelContextCleared. Check the description on a skipped or blocked event for the reason. A scheduling event does not establish that a notification was displayed.
iOS notification routing
Capacitor gives local notifications a single handler slot. Stay22 handles its notifications and chains other notifications to the preceding handler. From plugin 0.1.2, if the normal local-notifications plugin takes the slot after Stay22, Stay22 reclaims it and can adopt that handler when the app becomes active. A further plugin claiming the slot when a predecessor already exists can still disrupt that further plugin; load it before Stay22 and verify both notification flows.
const { value: installed } = await Stay22.isNotificationHandlerInstalled();If handleApplicationNotifications: false is set in capacitor.config.ts, your own notification delegate receives the callbacks instead of Capacitor's router. Forward responses to native Stay22.handleNotificationResponse(_:) and foreground presentations to Stay22.handleWillPresentNotification(_:) from that delegate. Forward each callback once. The tagged package README describes this integration. Android taps use the native SDK's activity and this handler check returns true there.
Testing covers a short delivery-and-tap check.