NativePushNotificationManagerIOS.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow
  9. */
  10. import type {TurboModule} from '../TurboModule/RCTExport';
  11. import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
  12. type Permissions = {|
  13. alert: boolean,
  14. badge: boolean,
  15. sound: boolean,
  16. |};
  17. type Notification = {|
  18. +alertTitle?: ?string,
  19. // Actual type: string | number
  20. +fireDate?: ?number,
  21. +alertBody?: ?string,
  22. +alertAction?: ?string,
  23. +userInfo?: ?Object,
  24. +category?: ?string,
  25. // Actual type: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute'
  26. +repeatInterval?: ?string,
  27. +applicationIconBadgeNumber?: ?number,
  28. +isSilent?: ?boolean,
  29. |};
  30. export interface Spec extends TurboModule {
  31. +getConstants: () => {...};
  32. +onFinishRemoteNotification: (
  33. notificationId: string,
  34. /**
  35. * Type:
  36. * 'UIBackgroundFetchResultNewData' |
  37. * 'UIBackgroundFetchResultNoData' |
  38. * 'UIBackgroundFetchResultFailed'
  39. */
  40. fetchResult: string,
  41. ) => void;
  42. +setApplicationIconBadgeNumber: (num: number) => void;
  43. +getApplicationIconBadgeNumber: (callback: (num: number) => void) => void;
  44. +requestPermissions: (permission: {|
  45. +alert: boolean,
  46. +badge: boolean,
  47. +sound: boolean,
  48. |}) => Promise<Permissions>;
  49. +abandonPermissions: () => void;
  50. +checkPermissions: (callback: (permissions: Permissions) => void) => void;
  51. +presentLocalNotification: (notification: Notification) => void;
  52. +scheduleLocalNotification: (notification: Notification) => void;
  53. +cancelAllLocalNotifications: () => void;
  54. +cancelLocalNotifications: (userInfo: Object) => void;
  55. +getInitialNotification: () => Promise<?Notification>;
  56. +getScheduledLocalNotifications: (
  57. callback: (notification: Notification) => void,
  58. ) => void;
  59. +removeAllDeliveredNotifications: () => void;
  60. +removeDeliveredNotifications: (identifiers: Array<string>) => void;
  61. +getDeliveredNotifications: (
  62. callback: (notification: Array<Notification>) => void,
  63. ) => void;
  64. +addListener: (eventType: string) => void;
  65. +removeListeners: (count: number) => void;
  66. }
  67. export default (TurboModuleRegistry.get<Spec>(
  68. 'PushNotificationManager',
  69. ): ?Spec);