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
{{ message }}
This repository was archived by the owner on Apr 4, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: docs/AUTHENTICATION.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,8 +189,14 @@ Don't forget to enable Facebook login in your firebase instance.
189
189
)
190
190
```
191
191
192
-
And also, add [this bit to `app.js`](https://github.com/EddyVerbruggen/nativescript-plugin-firebase-demo/blob/master/Firebase/app/app.js#L5-L34) to give control back to your app after Facebook's auth UI finished.
192
+
#### Start-up wiring
193
+
We need to do some wiring when your app starts, so open `app.js` and add this before `application.start();`:
193
194
195
+
```js
196
+
var firebase =require("nativescript-plugin-firebase");
197
+
```
198
+
199
+
_Note that if you previously added some other code for this plugin to `app.js` you can now go ahead and remove it._
Version 3.3.0 of this plugin added FCM support (which is the successor of GCM).
10
+
11
+
Although using push messages in your Firebase app is really easy setting it up is not. Traditionally, especially for iOS.
12
+
13
+
### Android
14
+
Work in progress.
15
+
16
+
### iOS
17
+
18
+
#### Receiving remote notifications in the background
19
+
Open `app/App_Resources/iOS/Info.plist` and add this to the bottom:
20
+
21
+
```xml
22
+
<key>UIBackgroundModes</key>
23
+
<array>
24
+
<string>remote-notification</string>
25
+
</array>
26
+
```
27
+
28
+
#### Provisioning hell
29
+
Follow [this guide](https://firebase.google.com/docs/cloud-messaging/ios/certs) to the letter. Once you've done it run `tns run ios` and upon starting the app it should prompt you for notification support. That also works on the simulator, but actually receiving notifications is _only_ possible on a real device.
30
+
31
+
## Functions
32
+
I tried to make this as simple as possible, so everything is handled for you transparently. If you want to act upon the notification that triggered opening your app then configure a callback handler as follows.
33
+
34
+
### Handling a notification
35
+
To listen to received notifications while in the foreground or when your app moves from the background to the foreground, add a handler `init`.
36
+
37
+
Any pending notifications (while your app was not in the foreground) will trigger the `onMessageReceivedCallback` handler.
38
+
39
+
```js
40
+
firebase.init({
41
+
onMessageReceivedCallback:function(message) {
42
+
console.log("Title: "+message.title);
43
+
console.log("Body: "+message.body);
44
+
// if your server passed a custom property called 'foo', then do this:
45
+
console.log("Value of 'foo': "+message.foo);
46
+
});
47
+
```
48
+
49
+
You don't _have_ to provide the handler during `init` - you can also do it through a dedicated function.
0 commit comments