You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Receiving notifications in any App state (foreground, background, "dead")
23
+
- Built-in notification drawer management
24
+
- High degree of code extensibility to allow for advanced custom layouts and specific notifications behavior as available by [Android's API](https://developer.android.com/training/notify-user/build-notification.html)
25
+
- Android equivalent of React-Native's implementation of [`PushNotificationsIOS.getInitialNotification()`](https://facebook.github.io/react-native/docs/pushnotificationios.html#getinitialnotification).
26
+
27
+
>Upcoming: local notifications, background-state Rx queue (iOS equivalent)
23
28
24
29
## Installation
25
30
@@ -63,27 +68,29 @@ And the following methods to support registration and receiving notifications:
> Note: Explicit installation on Android is only required if you're planning on **receiving push notifications**. It is **not** needed if you're only going to use 'local' notifications.
73
+
> Installation on Android is necessary in case you wish to receive push notifications on your React-Native app.
69
74
70
-
Push notifications on Android are managed and dispatched using [Google's GCM service](https://developers.google.com/cloud-messaging/gcm) (now integrated into Firebase). The following installation steps are a TL;DR of [Google's GCM setup guide](https://developers.google.com/cloud-messaging/android/client). You can follow them to get GCM integrated quickly, but we recommend you in the very least have a peek at the guide's overview.
75
+
Push notifications on Android are managed and dispatched using [Google's GCM service](https://developers.google.com/cloud-messaging/gcm) (now integrated into Firebase). The following installation steps are a TL;DR of [Google's GCM setup guide](https://developers.google.com/cloud-messaging/android/client). You can follow them to get GCM integrated quickly, but we recommend that you will in the very least have a peek at the guide's overview.
71
76
72
77
#### Step #1: Subscribe to Google's GCM
73
78
74
-
To set GCM in your app, you must first create a Google Firebase API-project and obtain a **Sender ID** and a **Server API Key**. If you have no existing API projects yet, the easiest way to go about is to create a project and get these attributes using [this step-by-step installation process](https://developers.google.com/mobile/add); Use [this tutorial](https://code.tutsplus.com/tutorials/how-to-get-started-with-push-notifications-on-android--cms-25870) for insturctions.
79
+
To set GCM in your app, you must first create a Google API-project and obtain a **Sender ID** and a **Server API Key**. If you have no existing API projects yet, the easiest way to go about in creating one is using [this step-by-step installation process](https://developers.google.com/mobile/add); Use [this tutorial](https://code.tutsplus.com/tutorials/how-to-get-started-with-push-notifications-on-android--cms-25870) for insturctions.
console.log("Notification opened by device user", notification);
156
182
}
157
183
158
184
componentWillUnmount() {
@@ -163,7 +189,7 @@ componentWillUnmount() {
163
189
}
164
190
```
165
191
166
-
### Notification Object
192
+
####Notification Object
167
193
When you receive a push notification, you'll get an instance of `IOSNotification` object, contains the following methods:
168
194
169
195
-**`getMessage()`**- returns the notification's main message string.
@@ -173,17 +199,60 @@ When you receive a push notification, you'll get an instance of `IOSNotification
173
199
-**`getData()`**- returns the data payload (additional info) of the notification.
174
200
-**`getType()`**- returns `managed` for managed notifications, otherwise returns `regular`.
175
201
176
-
177
-
### Background Queue (Important!)
202
+
#### Background Queue (Important!)
178
203
When a push notification is opened but the app is not running, the application will be in a **cold launch** state, until the JS engine is up and ready to handle the notification.
179
204
The application will collect the events (notifications, actions, etc.) that happend during the cold launch for you.
180
205
181
206
When your app is ready (most of the time it's after the call to `requestPermissions()`), just call to `NotificationsIOS.consumeBackgroundQueue();` in order to consume the background queue. For more info see `index.ios.js` in the example app.
console.log("Notification opened by device user", notification.getData());
219
+
});
220
+
```
221
+
222
+
#### Notification Object
223
+
-**`getData()`**- content of the `data` section of the original message (sent to GCM).
224
+
-**`getTitle()`**- Convenience for returning `data.title`.
225
+
-**`getMessage()`**- Convenience for returning `data.body`.
226
+
183
227
---
184
228
229
+
## Querying initial notification
230
+
231
+
React-Native's [`PushNotificationsIOS.getInitialNotification()`](https://facebook.github.io/react-native/docs/pushnotificationios.html#getinitialnotification) allows for the async retrieval of the original notification used to open the App on iOS, but it has no equivalent implementation for Android.
232
+
233
+
We provide a similar implementation on Android using `PendingNotifications.getInitialNotification()` which returns a promise:
0 commit comments