From 73ae35f48fa84043e67271fe712aa8f8e179b370 Mon Sep 17 00:00:00 2001 From: foxmicha Date: Mon, 11 Dec 2017 15:48:12 -0500 Subject: [PATCH] Update react-native PushNotificationIOS Typings React-Native typings are currently missing two crucial definitions when implementing iOS notifications: finish function and FetchResult strings. If a finish function is not called, the background remote notifications could be throttled. Sources: https://facebook.github.io/react-native/docs/pushnotificationios.html#finish https://github.com/facebook/react-native/blob/master/Libraries/PushNotificationIOS/PushNotificationIOS.js#L133 https://github.com/facebook/react-native/blob/master/Libraries/PushNotificationIOS/PushNotificationIOS.js#L454 --- types/react-native/index.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index da6ab1e24f..ac5b1c57d2 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7160,6 +7160,12 @@ export interface PushNotification { * Gets the data object on the notif */ getData(): Object; + + /** + * iOS Only + * Signifies remote notification handling is complete + */ + finish(result: string): void; } type PresentLocalNotificationDetails = { @@ -7182,6 +7188,12 @@ type ScheduleLocalNotificationDetails = { }; export type PushNotificationEventName = "notification" | "localNotification" | "register" | "registrationError"; + +type FetchResult = { + NewData: "UIBackgroundFetchResultNewData", + NoData: "UIBackgroundFetchResultNoData", + ResultFailed: "UIBackgroundFetchResultFailed" +}; /** * Handle push notifications for your app, including permission handling and icon badge number. @@ -7296,6 +7308,12 @@ export interface PushNotificationIOSStatic { * object if the app was launched by a push notification, or `null` otherwise. */ getInitialNotification(): Promise; + + /** + * iOS fetch results that best describe the result of a finished remote notification handler. + * For a list of possible values, see `PushNotificationIOS.FetchResult`. + */ + FetchResult: FetchResult; } export interface SettingsStatic {