Skip to main content

@amisi-mobile-starter/notifications

@amisi-mobile-starter/notifications registers mock by default and lazily loads onesignal or expo when selected.

Initialize

OneSignal requires options.appId. The Expo adapter ignores initialization options. The mobile root reads the selected adapter from amisiConfig.notifications, injects EXPO_PUBLIC_ONE_SIGNAL_APP_ID for OneSignal, then initializes and registers after authentication.

Hook API

useNotifications() does not require a provider. It returns:
NotificationPreferences has required push, emailDigest, and smsAlerts booleans. The current setNotificationPreferences implementation only logs the request; it does not persist or send preferences.

Runtime API

The non-hook equivalents are requestNotificationPermission, getNotificationPermissionStatus, registerForPushNotifications, unregisterPushNotifications, and setNotificationPreferences. Subscribe with:
Both listener functions return no-op unsubscribers before initialization. Permission reads, permission requests, and registration throw when no adapter is active. Unregistration returns silently. PushToken.provider is onesignal | expo. Expo registration requires a physical device, granted permission, and Constants.expoConfig.extra.eas.projectId. The mock adapter returns { token: 'mock-push-token', provider: 'expo' }.