From c6c4d0f310ff3307e5414d23391493c07879917c Mon Sep 17 00:00:00 2001 From: yogevbd Date: Wed, 2 Oct 2019 13:44:37 +0300 Subject: [PATCH] Finish API documentation --- .gitignore | 1 + docs/android-api.md | 4 ++-- docs/doc2.md | 7 ------- docs/doc3.md | 13 ------------- docs/exampledoc4.md | 6 ------ docs/exampledoc5.md | 6 ------ docs/general-api.md | 12 ++++++++++-- docs/general-events.md | 25 +++++++++++++----------- docs/ios-api.md | 44 ++++++++++++++++++++++-------------------- docs/ios-events.md | 8 ++++---- 10 files changed, 54 insertions(+), 72 deletions(-) delete mode 100755 docs/doc2.md delete mode 100755 docs/doc3.md delete mode 100755 docs/exampledoc4.md delete mode 100755 docs/exampledoc5.md diff --git a/.gitignore b/.gitignore index 00c5396..82b4d3a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ lib/android/*.iml lib/android/.idea lib/android/build lib/android/.gradle +*.gradle ##### # OS X temporary files that should never be committed diff --git a/docs/android-api.md b/docs/android-api.md index 7ce9e3f..9ee6f98 100755 --- a/docs/android-api.md +++ b/docs/android-api.md @@ -4,8 +4,8 @@ title: Android Specific Commands sidebar_label: Android specific --- -## refreshToken -refreshToken +## refreshToken() +Request a new token for sending push notifications. ```js Notifications.android.refreshToken(); diff --git a/docs/doc2.md b/docs/doc2.md deleted file mode 100755 index 20c0c95..0000000 --- a/docs/doc2.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -id: doc2 -title: document number 2 ---- - -This is a link to [another document.](doc3.md) -This is a link to an [external page.](http://www.example.com) diff --git a/docs/doc3.md b/docs/doc3.md deleted file mode 100755 index bcb9054..0000000 --- a/docs/doc3.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -id: doc3 -title: This is document number 3 ---- -Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac euismod odio, eu consequat dui. Nullam molestie consectetur risus id imperdiet. Proin sodales ornare turpis, non mollis massa ultricies id. Nam at nibh scelerisque, feugiat ante non, dapibus tortor. Vivamus volutpat diam quis tellus elementum bibendum. Praesent semper gravida velit quis aliquam. Etiam in cursus neque. Nam lectus ligula, malesuada et mauris a, bibendum faucibus mi. Phasellus ut interdum felis. Phasellus in odio pulvinar, porttitor urna eget, fringilla lectus. Aliquam sollicitudin est eros. Mauris consectetur quam vitae mauris interdum hendrerit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - -Duis et egestas libero, imperdiet faucibus ipsum. Sed posuere eget urna vel feugiat. Vivamus a arcu sagittis, fermentum urna dapibus, congue lectus. Fusce vulputate porttitor nisl, ac cursus elit volutpat vitae. Nullam vitae ipsum egestas, convallis quam non, porta nibh. Morbi gravida erat nec neque bibendum, eu pellentesque velit posuere. Fusce aliquam erat eu massa eleifend tristique. - -Sed consequat sollicitudin ipsum eget tempus. Integer a aliquet velit. In justo nibh, pellentesque non suscipit eget, gravida vel lacus. Donec odio ante, malesuada in massa quis, pharetra tristique ligula. Donec eros est, tristique eget finibus quis, semper non nisl. Vivamus et elit nec enim ornare placerat. Sed posuere odio a elit cursus sagittis. - -Phasellus feugiat purus eu tortor ultrices finibus. Ut libero nibh, lobortis et libero nec, dapibus posuere eros. Sed sagittis euismod justo at consectetur. Nulla finibus libero placerat, cursus sapien at, eleifend ligula. Vivamus elit nisl, hendrerit ac nibh eu, ultrices tempus dui. Nam tellus neque, commodo non rhoncus eu, gravida in risus. Nullam id iaculis tortor. - -Nullam at odio in sem varius tempor sit amet vel lorem. Etiam eu hendrerit nisl. Fusce nibh mauris, vulputate sit amet ex vitae, congue rhoncus nisl. Sed eget tellus purus. Nullam tempus commodo erat ut tristique. Cras accumsan massa sit amet justo consequat eleifend. Integer scelerisque vitae tellus id consectetur. diff --git a/docs/exampledoc4.md b/docs/exampledoc4.md deleted file mode 100755 index 6f94ffe..0000000 --- a/docs/exampledoc4.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -id: doc4 -title: Other Document ---- - -this is another document diff --git a/docs/exampledoc5.md b/docs/exampledoc5.md deleted file mode 100755 index 92e2d0d..0000000 --- a/docs/exampledoc5.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -id: doc5 -title: Fifth Document ---- - -Another one diff --git a/docs/general-api.md b/docs/general-api.md index 49d0964..06b787a 100755 --- a/docs/general-api.md +++ b/docs/general-api.md @@ -4,8 +4,16 @@ title: General Commands sidebar_label: General --- -## getInitialNotification -Return the notification that caused the app to launch from dead state. +## registerRemoteNotifications() +Requests remote notification permissions, prompting the user's dialog box on iOS and request a token on Android. +If the user accept the remote notifications permissions, `RemoteNotificationsRegistered` event will get called with the device token. + +```js +Notifications.registerRemoteNotifications(); +``` + +## getInitialNotification() +This method returns a promise. If the app was launched by a push notification, this promise resolves to an object of type Notification. Otherwise, it resolves to undefined. ```js const notification: Notification = await Notifications.getInitialNotification(); diff --git a/docs/general-events.md b/docs/general-events.md index a3f7b6b..fbb1f27 100755 --- a/docs/general-events.md +++ b/docs/general-events.md @@ -4,8 +4,8 @@ title: General sidebar_label: General --- -## registerRemoteNotificationsRegistered -registerRemoteNotificationsRegistered +## registerRemoteNotificationsRegistered() +Fired when the user registers for remote notifications. The handler will be invoked with an event holding the hex string representing the `deviceToken` ```js Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => { @@ -13,8 +13,9 @@ Notifications.events().registerRemoteNotificationsRegistered((event: Registered) }); ``` -## registerNotificationReceived -registerNotificationReceived +## registerNotificationReceived() +Fired when a remote notification is received in foreground state. The handler will be invoked with an instance of `Notification`. +Should call completion function on iOS, will be ignored on Android. ```js Notifications.events().registerNotificationReceived((notification: Notification, completion: (response: NotificationCompletion) => void) => { @@ -25,20 +26,22 @@ Notifications.events().registerNotificationReceived((notification: Notification, }); ``` -## registerRemoteNotificationOpened -registerRemoteNotificationOpened +## registerRemoteNotificationOpened() +Fired when a remote notification is opened from dead or background state. The handler will be invoked with an instance of `Notification`. +Should call completion function on iOS, will be ignored on Android. ```js -Notifications.events().registerRemoteNotificationOpened((notification: Notification) => { +Notifications.events().registerRemoteNotificationOpened((notification: Notification, completion: () => void) => { console.log(JSON.stringify(notification.data)); + completion(); }); ``` -## registerRemoteNotificationsRegistrationFailed -registerRemoteNotificationsRegistrationFailed +## registerRemoteNotificationsRegistrationFailed() +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 {localizedDescription: string, code: string, domain: string}. ```js -Notifications.events().registerRemoteNotificationsRegistrationFailed(() => { - +Notifications.events().registerRemoteNotificationsRegistrationFailed((event: RegistrationError) => { + console.log(event.code, event.localizedDescription, event.domain); }); ``` \ No newline at end of file diff --git a/docs/ios-api.md b/docs/ios-api.md index 8c034dc..bc1b8d1 100755 --- a/docs/ios-api.md +++ b/docs/ios-api.md @@ -4,71 +4,73 @@ title: iOS Specific Commands sidebar_label: iOS specific --- -## requestPermissions -request permissions +## requestPermissions() +Requests notification permissions from iOS, prompting the user's dialog box. ```js Notifications.ios.requestPermissions(); ``` -## checkPermissions -checkPermissions +## checkPermissions() +See what push permissions are currently enabled. ```js Notifications.ios.checkPermissions(); ``` -## abandonPermissions -Unregister for all remote notifications received via Apple Push Notification service +## abandonPermissions() +Unregister for all remote notifications received via Apple Push Notification service. + +You should call this method in rare circumstances only, such as when a new version of the app removes support for all types of remote notifications. Users can temporarily prevent apps from receiving remote notifications through the Notifications section of the Settings app. Apps unregistered through this method can always re-register. ```js Notifications.ios.abandonPermissions(); ``` -## registerPushKit -registerPushKit +## registerPushKit() +Register for PushKit notifications ```js Notifications.ios.registerPushKit(); ``` -## cancelAllLocalNotifications -cancelAllLocalNotifications +## cancelAllLocalNotifications() +Cancels all scheduled localNotifications ```js Notifications.ios.cancelAllLocalNotifications(); ``` -## getDeliveredNotifications -getDeliveredNotifications +## getDeliveredNotifications() +Provides you with a list of the app’s notifications that are still displayed in Notification Center ```js Notifications.ios.getDeliveredNotifications(); ``` -## removeAllDeliveredNotifications -removeAllDeliveredNotifications +## removeAllDeliveredNotifications() +Remove all delivered notifications from Notification Center ```js Notifications.ios.removeAllDeliveredNotifications(); ``` -## removeDeliveredNotifications -removeDeliveredNotifications +## removeDeliveredNotifications() +Removes the specified notifications from Notification Center ```js -Notifications.ios.removeDeliveredNotifications(); +Notifications.ios.removeDeliveredNotifications(identifiers); ``` -## getBadgeCount -getBadgeCount +## getBadgeCount() +Gets the badge count number from the aps object ```js Notifications.ios.getBadgeCount(); ``` -## setBadgeCount -setBadgeCount +## setBadgeCount() +Sets the badge number for the app icon on the home screen ```js Notifications.ios.setBadgeCount(1); diff --git a/docs/ios-events.md b/docs/ios-events.md index f71c385..603bd7d 100755 --- a/docs/ios-events.md +++ b/docs/ios-events.md @@ -4,8 +4,8 @@ title: iOS sidebar_label: iOS specific --- -## registerPushKitRegistered -registerPushKitRegistered +## registerPushKitRegistered() +Fired when the user registers for PushKit notifications. The handler will be invoked with an event holding the hex string representing the `pushKitToken` ```js Notifications.events().registerPushKitRegistered((event: RegisteredPushKit) => { @@ -13,8 +13,8 @@ Notifications.events().registerPushKitRegistered((event: RegisteredPushKit) => { }); ``` -## registerPushKitNotificationReceived -registerPushKitNotificationReceived +## registerPushKitNotificationReceived() +Fired when a PushKit notification is received. The handler will be invoked with the notification object. ```js Notifications.events().registerPushKitNotificationReceived((event: object) => { -- 2.26.2