Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript typing #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
declare module '@voximplant/react-native-foreground-service' {
export interface NotificationChannelConfig {
/**
* Unique channel ID
*/
id: string;
/**
* Notification channel name
*/
name: string;
/**
* Notification channel description
*/
description?: string;
/**
* Notification channel importance.
* One of:
* 1 - 'min',
* 2 - 'low' (by default),
* 3 - 'default',
* 4 - 'high',
* 5 - 'max'.
*/
importance?: 1 | 2 | 3 | 4 | 5;
/**
* Sets whether notification posted to this channel should vibrate. False by default.
*/
enableVibration?: boolean;
}

export interface NotificationConfig {
/**
* Notification channel id to display notification
*/
channelId: string;
/**
* Unique notification id
*/
id: number;
/**
* Notification title
*/
title: string;
/**
* Notification text
*/
text: string;
/**
* Small icon name
*/
icon: string;
/**
* Priority of this notification.
* One of:
* 0 - PRIORITY_DEFAULT (by default),
* -1 - PRIORITY_LOW,
* -2 - PRIORITY_MIN,
* 1 - PRIORITY_HIGH,
* 2 - PRIORITY_MAX
*/
priority?: -2 | -1 | 0 | 1 | 2;
}

export default class VIForegroundService {
/**
* Create notification channel for foreground service
* @param {NotificationChannelConfig} channelConfig - Notification channel configuration
* @return Promise
*/
static createNotificationChannel(
channelConfig: NotificationChannelConfig,
): Promise<void>;

/**
* Start foreground service
* @param {NotificationConfig} notificationConfig - Notification config
* @return Promise
*/
static startService(notificationConfig: NotificationConfig): Promise<void>;

/**
* Stop foreground service
* @return Promise
*/
static stopService(): Promise<void>;
}
}
15 changes: 15 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es6"], /* Specify library files to be included in the compilation. */
"allowJs": true, /* Allow javascript files to be compiled. */
"noEmit": true, /* Do not emit outputs. */
"isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"strict": true, /* Enable all strict type-checking options. */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
},
"exclude": [
"node_modules"
]
}