Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ export type FetchResult = {
export type PushNotificationEventName = $Keys<{
/**
* Fired when a remote notification is received. The handler will be invoked
* with an instance of `PushNotificationIOS`.
* with an instance of `PushNotificationIOS`. This will handle notifications
* that arrive in the foreground or were tapped to open the app from the
* background.
*/
notification: string,
/**
* Fired when a local notification is received. The handler will be invoked
* with an instance of `PushNotificationIOS`.
* with an instance of `PushNotificationIOS`. This will handle notifications
* that arrive in the foreground or were tapped to open the app from the
* background.
*/
localNotification: string,
/**
Expand All @@ -83,17 +87,16 @@ export type PushNotificationEventName = $Keys<{
register: string,
/**
* Fired when the user fails to register for remote notifications. Typically
* occurs when APNS is having issues, or the device is a simulator. The
* handler will be invoked with {message: string, code: number, details: any}.
* occurs due to APNS issues or if the device is a simulator. The handler
* will be invoked with {message: string, code: number, details: any}.
*/
registrationError: string,
...
}>;

/**
*
* Handle push notifications for your app, including permission handling and
* icon badge number.
* Handle notifications for your app, including scheduling and permissions.
*
* See https://reactnative.dev/docs/pushnotificationios
*/
Expand All @@ -116,7 +119,7 @@ class PushNotificationIOS {
};

/**
* Schedules the localNotification for immediate presentation.
* Schedules a local notification for immediate presentation.
*
* See https://reactnative.dev/docs/pushnotificationios#presentlocalnotification
*/
Expand All @@ -129,7 +132,7 @@ class PushNotificationIOS {
}

/**
* Schedules the localNotification for future presentation.
* Schedules a local notification for future presentation.
*
* See https://reactnative.dev/docs/pushnotificationios#schedulelocalnotification
*/
Expand All @@ -142,7 +145,7 @@ class PushNotificationIOS {
}

/**
* Cancels all scheduled localNotifications.
* Cancels all scheduled local notifications.
*
* See https://reactnative.dev/docs/pushnotificationios#cancelalllocalnotifications
*/
Expand All @@ -155,7 +158,7 @@ class PushNotificationIOS {
}

/**
* Remove all delivered notifications from Notification Center.
* Removes all delivered notifications from Notification Center.
*
* See https://reactnative.dev/docs/pushnotificationios#removealldeliverednotifications
*/
Expand All @@ -168,7 +171,8 @@ class PushNotificationIOS {
}

/**
* Provides you with a list of the app’s notifications that are still displayed in Notification Center.
* Provides a list of the app’s notifications that are currently displayed
* in Notification Center.
*
* See https://reactnative.dev/docs/pushnotificationios#getdeliverednotifications
*/
Expand All @@ -183,7 +187,7 @@ class PushNotificationIOS {
}

/**
* Removes the specified notifications from Notification Center
* Removes the specified notifications from Notification Center.
*
* See https://reactnative.dev/docs/pushnotificationios#removedeliverednotifications
*/
Expand All @@ -196,7 +200,7 @@ class PushNotificationIOS {
}

/**
* Sets the badge number for the app icon on the home screen.
* Sets the badge number for the app icon on the Home Screen.
*
* See https://reactnative.dev/docs/pushnotificationios#setapplicationiconbadgenumber
*/
Expand All @@ -209,7 +213,7 @@ class PushNotificationIOS {
}

/**
* Gets the current badge number for the app icon on the home screen.
* Gets the current badge number for the app icon on the Home Screen.
*
* See https://reactnative.dev/docs/pushnotificationios#getapplicationiconbadgenumber
*/
Expand All @@ -222,7 +226,8 @@ class PushNotificationIOS {
}

/**
* Cancel local notifications.
* Cancels any scheduled local notifications which match the fields in the
* provided `userInfo`.
*
* See https://reactnative.dev/docs/pushnotificationios#cancellocalnotification
*/
Expand All @@ -235,7 +240,7 @@ class PushNotificationIOS {
}

/**
* Gets the local notifications that are currently scheduled.
* Gets the list of local notifications that are currently scheduled.
*
* See https://reactnative.dev/docs/pushnotificationios#getscheduledlocalnotifications
*/
Expand All @@ -248,8 +253,8 @@ class PushNotificationIOS {
}

/**
* Attaches a listener to remote or local notification events while the app
* is running in the foreground or the background.
* Attaches a listener to notification events including local notifications,
* remote notifications, and notification registration results.
*
* See https://reactnative.dev/docs/pushnotificationios#addeventlistener
*/
Expand Down Expand Up @@ -303,10 +308,7 @@ class PushNotificationIOS {
*
* See https://reactnative.dev/docs/pushnotificationios#removeeventlistener
*/
static removeEventListener(
type: PushNotificationEventName,
handler: Function,
): void {
static removeEventListener(type: PushNotificationEventName): void {
invariant(
type === 'notification' ||
type === 'register' ||
Expand All @@ -323,10 +325,9 @@ class PushNotificationIOS {
}

/**
* Requests notification permissions from iOS, prompting the user's
* Requests notification permissions from iOS, prompting the user with a
* dialog box. By default, it will request all notification permissions, but
* a subset of these can be requested by passing a map of requested
* permissions.
* you can optionally specify which permissions to request.
*
* See https://reactnative.dev/docs/pushnotificationios#requestpermissions
*/
Expand Down Expand Up @@ -363,7 +364,8 @@ class PushNotificationIOS {
}

/**
* Unregister for all remote notifications received via Apple Push Notification service.
* Unregister for all remote notifications received via Apple Push Notification
* service. This should be called in rare circumstances only.
*
* See https://reactnative.dev/docs/pushnotificationios#abandonpermissions
*/
Expand All @@ -376,8 +378,8 @@ class PushNotificationIOS {
}

/**
* See what push permissions are currently enabled. `callback` will be
* invoked with a `permissions` object.
* Check which push permissions are currently enabled. `callback` will be
* invoked with a `Permissions` object.
*
* See https://reactnative.dev/docs/pushnotificationios#checkpermissions
*/
Expand Down Expand Up @@ -409,7 +411,8 @@ class PushNotificationIOS {
}

/**
* This method returns a promise that resolves to notification authorization status.
* This method returns a promise that resolves to the current notification
* authorization status. See UNAuthorizationStatus for possible values.
*/
static getAuthorizationStatus(
callback: (authorizationStatus: number) => void,
Expand All @@ -425,7 +428,7 @@ class PushNotificationIOS {
/**
* You will never need to instantiate `PushNotificationIOS` yourself.
* Listening to the `notification` event and invoking
* `getInitialNotification` is sufficient
* `getInitialNotification` is sufficient.
*
*/
constructor(nativeNotif: Object) {
Expand Down Expand Up @@ -464,7 +467,8 @@ class PushNotificationIOS {

/**
* This method is available for remote notifications that have been received via:
* `application:didReceiveRemoteNotification:fetchCompletionHandler:`
* `application:didReceiveRemoteNotification:fetchCompletionHandler:`. See docs
* for more information.
*
* See https://reactnative.dev/docs/pushnotificationios#finish
*/
Expand All @@ -489,15 +493,16 @@ class PushNotificationIOS {
}

/**
* An alias for `getAlert` to get the notification's main message string
* An alias for `getAlert` to get the notification's main message string.
*/
getMessage(): ?string | ?Object {
// alias because "alert" is an ambiguous name
return this._alert;
}

/**
* Gets the sound string from the `aps` object
* Gets the sound string from the `aps` object. This will be `null` for local
* notifications.
*
* See https://reactnative.dev/docs/pushnotificationios#getsound
*/
Expand All @@ -506,7 +511,7 @@ class PushNotificationIOS {
}

/**
* Gets the category string from the `aps` object
* Gets the category string from the `aps` object.
*
* See https://reactnative.dev/docs/pushnotificationios#getcategory
*/
Expand All @@ -515,7 +520,8 @@ class PushNotificationIOS {
}

/**
* Gets the notification's main message from the `aps` object
* Gets the notification's main message from the `aps` object. Also see the
* alias: `getMessage()`.
*
* See https://reactnative.dev/docs/pushnotificationios#getalert
*/
Expand All @@ -524,7 +530,7 @@ class PushNotificationIOS {
}

/**
* Gets the content-available number from the `aps` object
* Gets the content-available number from the `aps` object.
*
* See https://reactnative.dev/docs/pushnotificationios#getcontentavailable
*/
Expand All @@ -533,7 +539,7 @@ class PushNotificationIOS {
}

/**
* Gets the badge count number from the `aps` object
* Gets the badge count number from the `aps` object.
*
* See https://reactnative.dev/docs/pushnotificationios#getbadgecount
*/
Expand All @@ -542,7 +548,7 @@ class PushNotificationIOS {
}

/**
* Gets the data object on the notif
* Gets the data object on the notification.
*
* See https://reactnative.dev/docs/pushnotificationios#getdata
*/
Expand All @@ -551,7 +557,7 @@ class PushNotificationIOS {
}

/**
* Gets the thread ID on the notif
* Gets the thread ID on the notification.
*
* See https://reactnative.dev/docs/pushnotificationios#getthreadid
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6372,10 +6372,7 @@ declare class PushNotificationIOS {
type: PushNotificationEventName,
handler: Function
): void;
static removeEventListener(
type: PushNotificationEventName,
handler: Function
): void;
static removeEventListener(type: PushNotificationEventName): void;
static requestPermissions(permissions?: {
alert?: boolean,
badge?: boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ type Notification = {|
/** Whether to silence the notification sound. */
+isSilent?: ?boolean,
/**
* Custom notification sound to play. Write-only: soundName will be null when
* accessing already created notifications using getScheduledLocalNotifications
* or getDeliveredNotifications.
* Custom notification sound. Can only be set when creating notifications.
* This will be null for notifications retrieved via
* getScheduledLocalNotifications or getDeliveredNotifications.
*/
+soundName?: ?string,
/** DEPRECATED. This was used for iOS's legacy UILocalNotification. */
Expand Down