notification-kit
Version:
A unified notification library for React + Capacitor apps. One API for push notifications, in-app notifications, and local notifications across Web, iOS, and Android.
122 lines (114 loc) • 4.1 kB
TypeScript
// Type declarations for external modules
declare module 'firebase/app' {
export interface FirebaseApp {
name: string
options: Record<string, any>
}
export function initializeApp(config: any): FirebaseApp
export function getApp(): FirebaseApp
}
declare module 'firebase/messaging' {
export interface Messaging {}
export interface MessagePayload {
from?: string
collapseKey?: string
data?: Record<string, any>
notification?: {
title?: string
body?: string
icon?: string
image?: string
badge?: string
sound?: string
tag?: string
color?: string
clickAction?: string
}
}
export function getMessaging(app?: any): Messaging
export function getToken(messaging: Messaging, options?: any): Promise<string>
export function deleteToken(messaging: Messaging): Promise<boolean>
export function onMessage(messaging: Messaging, callback: (payload: MessagePayload) => void): () => void
export function onTokenRefresh(messaging: Messaging, callback: () => void): () => void
export function isSupported(): Promise<boolean>
}
declare module 'react-onesignal' {
const OneSignal: {
init(options: any): Promise<void>
setExternalUserId(userId: string): Promise<void>
removeExternalUserId(): Promise<void>
getExternalUserId(): Promise<string>
getTags(): Promise<any>
sendTag(key: string, value: string): Promise<void>
sendTags(tags: Record<string, string>): Promise<void>
deleteTag(key: string): Promise<void>
deleteTags(keys: string[]): Promise<void>
on(event: string, callback: Function): void
off(event: string, callback: Function): void
showNativePrompt(): Promise<void>
registerForPushNotifications(): Promise<void>
setSubscription(unmute: boolean): Promise<void>
isPushNotificationsEnabled(): Promise<boolean>
setEmail(email: string): Promise<void>
logoutEmail(): Promise<void>
setLanguage(language: string): Promise<void>
getUserId(): Promise<string>
getPermissionStatus(): Promise<string>
}
export default OneSignal
}
declare module '@capacitor/push-notifications' {
export const PushNotifications: {
register(): Promise<void>
requestPermissions(): Promise<any>
checkPermissions(): Promise<any>
getDeliveredNotifications(): Promise<any>
removeDeliveredNotifications(options: any): Promise<void>
removeAllDeliveredNotifications(): Promise<void>
createChannel(channel: any): Promise<void>
deleteChannel(channel: any): Promise<void>
listChannels(): Promise<any>
addListener(event: string, callback: Function): Promise<any>
}
}
declare module '@capacitor/local-notifications' {
export interface LocalNotificationChannel {
id: string
name: string
description?: string
importance: number
visibility?: number
sound?: string
vibration?: boolean
lights?: boolean
lightColor?: string
showBadge?: boolean
}
export type LocalNotificationSchema = any
export type Channel = LocalNotificationChannel
export type Importance = 1 | 2 | 3 | 4 | 5
export const LocalNotifications: {
schedule(options: any): Promise<any>
getPending(): Promise<any>
cancel(options: any): Promise<void>
registerActionTypes(options: any): Promise<void>
createChannel(channel: LocalNotificationChannel): Promise<void>
deleteChannel(options: any): Promise<void>
listChannels(): Promise<any>
checkPermissions(): Promise<any>
requestPermissions(): Promise<any>
addListener(event: string, callback: Function): Promise<any>
getDeliveredNotifications(): Promise<any>
removeDeliveredNotifications(options: any): Promise<void>
removeAllDeliveredNotifications(): Promise<void>
}
}
declare module '@capacitor/preferences' {
export const Preferences: {
set(options: { key: string; value: string }): Promise<void>
get(options: { key: string }): Promise<{ value: string | null }>
remove(options: { key: string }): Promise<void>
clear(): Promise<void>
keys(): Promise<{ keys: string[] }>
}
}