mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Merge pull request #21540 from PaitoAnderson/master
Added react-native-push-notification
This commit is contained in:
+89
@@ -0,0 +1,89 @@
|
||||
// Type definitions for react-native-push-notification 3.0
|
||||
// Project: https://github.com/zo0r/react-native-push-notification#readme
|
||||
// Definitions by: Paito Anderson <https://github.com/PaitoAnderson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export interface PushNotificationPermissions {
|
||||
alert?: boolean;
|
||||
badge?: boolean;
|
||||
sound?: boolean;
|
||||
}
|
||||
|
||||
export interface PushNotification {
|
||||
foreground: boolean;
|
||||
userInteraction: boolean;
|
||||
message: string|object;
|
||||
data: object;
|
||||
badge: number;
|
||||
alert: object;
|
||||
sound: string;
|
||||
}
|
||||
|
||||
export class PushNotificationOptions {
|
||||
onRegister?: (token: { os: string, token: string }) => void;
|
||||
onNotification?: (notification: PushNotification) => void;
|
||||
senderID?: string;
|
||||
popInitialNotification?: boolean;
|
||||
requestPermissions?: boolean;
|
||||
}
|
||||
|
||||
export type RepeatType = 'week' | 'day' | 'hour' | 'minute' | 'time';
|
||||
|
||||
export class PushNotificationObject {
|
||||
/* Android only properties */
|
||||
id?: string;
|
||||
ticker?: string;
|
||||
autoCancel?: boolean;
|
||||
largeIcon?: string;
|
||||
smallIcon?: string;
|
||||
bigText?: string;
|
||||
subText?: string;
|
||||
color?: string;
|
||||
vibrate?: boolean;
|
||||
vibration?: number;
|
||||
tag?: string;
|
||||
group?: string;
|
||||
ongoing?: boolean;
|
||||
|
||||
/* iOS only properties */
|
||||
alertAction?: any;
|
||||
category?: any;
|
||||
userInfo?: any;
|
||||
|
||||
/* iOS and Android properties */
|
||||
title?: string;
|
||||
message: string;
|
||||
playSound?: boolean;
|
||||
soundName?: string;
|
||||
number?: string;
|
||||
repeatType?: RepeatType;
|
||||
actions?: string;
|
||||
}
|
||||
|
||||
export class PushNotificationScheduleObject extends PushNotificationObject {
|
||||
Date: Date;
|
||||
}
|
||||
|
||||
export interface PushNotification {
|
||||
configure(options: PushNotificationOptions): void;
|
||||
unregister(): void;
|
||||
localNotification(details: PushNotificationObject): void;
|
||||
localNotificationSchedule(details: PushNotificationScheduleObject): void;
|
||||
requestPermissions(): void;
|
||||
presentLocalNotification(details: PushNotificationObject): void;
|
||||
scheduleLocalNotification(details: PushNotificationScheduleObject): void;
|
||||
cancelLocalNotifications(details: object): void;
|
||||
cancelAllLocalNotifications(): void;
|
||||
setApplicationIconBadgeNumber(badgeCount: number): void;
|
||||
getApplicationIconBadgeNumber(callback: (badgeCount: number) => void): void;
|
||||
popInitialNotification(): Promise<PushNotification>;
|
||||
abandonPermissions(): void;
|
||||
checkPermissions(callback: (permissions: PushNotificationPermissions) => void): void;
|
||||
registerNotificationActions(actions: string[]): void;
|
||||
clearAllNotifications(): void;
|
||||
}
|
||||
|
||||
declare const PushNotification: PushNotification;
|
||||
|
||||
export default PushNotification;
|
||||
@@ -0,0 +1,25 @@
|
||||
import PushNotification from 'react-native-push-notification';
|
||||
|
||||
PushNotification.configure({
|
||||
onNotification: (notification) => {},
|
||||
onRegister: (token) => {},
|
||||
senderID: 'XXX',
|
||||
popInitialNotification: false,
|
||||
requestPermissions: true,
|
||||
});
|
||||
|
||||
PushNotification.unregister();
|
||||
PushNotification.localNotification = (details) => {};
|
||||
PushNotification.localNotificationSchedule = (details) => {};
|
||||
PushNotification.requestPermissions();
|
||||
PushNotification.presentLocalNotification = (details) => {};
|
||||
PushNotification.scheduleLocalNotification = (details) => {};
|
||||
PushNotification.cancelLocalNotifications = (details) => {};
|
||||
PushNotification.cancelAllLocalNotifications();
|
||||
PushNotification.setApplicationIconBadgeNumber(1);
|
||||
PushNotification.getApplicationIconBadgeNumber((badgeCount) => {});
|
||||
PushNotification.popInitialNotification();
|
||||
PushNotification.checkPermissions((checkPermissions) => {});
|
||||
PushNotification.abandonPermissions();
|
||||
PushNotification.registerNotificationActions(['Accept', 'Reject', 'Yes', 'No']);
|
||||
PushNotification.clearAllNotifications();
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-push-notification-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user