Commit ff096c8c authored by yogevbd's avatar yogevbd

Add subscription documentation guide

parent 27da4aa2
---
id: subscription
title: Push Notifications Subscription
sidebar_label: Subscription
---
The typical flow for subscribing a device for receiving push notification in real time is to first register the device at the vendor's servers (e.g. FCM), then publishing the received token to your own push management servers.
This section is about the first part of the flow.
In order to handle notifications, you must register the `remoteNotificationsRegistered` event beforehand.
In your React Native app:
```javascript
import {Notifications} from 'react-native-notifications';
class App extends Component {
constructor() {
Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => {
// TODO: Send the token to my server so it could send back push notifications...
console.log("Device Token Received", event.deviceToken);
});
Notifications.events().registerRemoteNotificationsRegistrationFailed((event: RegistrationError) => {
console.error(event);
});
Notifications.requestPermissions();
}
}
```
When you have the device token, POST it to your server and register the device in your notifications provider (Amazon SNS, Azure, etc.).
You can check if the user granted permissions on iOS by calling `checkPermissions()`:
```javascript
Notifications.ios.checkPermissions().then((currentPermissions) => {
console.log('Badges enabled: ' + !!currentPermissions.badge);
console.log('Sounds enabled: ' + !!currentPermissions.sound);
console.log('Alerts enabled: ' + !!currentPermissions.alert);
});
```
...@@ -40,6 +40,10 @@ ...@@ -40,6 +40,10 @@
"notification-object": { "notification-object": {
"title": "Notification object", "title": "Notification object",
"sidebar_label": "Notification" "sidebar_label": "Notification"
},
"subscription": {
"title": "Push Notifications Subscription",
"sidebar_label": "Subscription"
} }
}, },
"links": { "links": {
...@@ -48,6 +52,7 @@ ...@@ -48,6 +52,7 @@
}, },
"categories": { "categories": {
"Installation": "Installation", "Installation": "Installation",
"Guides": "Guides",
"Advanced": "Advanced", "Advanced": "Advanced",
"Commands": "Commands", "Commands": "Commands",
"Events": "Events", "Events": "Events",
......
{ {
"docs": { "docs": {
"Installation": ["installation-ios", "installation-android"], "Installation": ["installation-ios", "installation-android"],
"Guides": ["subscription"],
"Advanced": ["advanced-ios"] "Advanced": ["advanced-ios"]
}, },
"api": { "api": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment