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 Feb 7, 2019. It is now read-only.
0. Run "tns doctor" and make sure everything is up to date
321
-
322
-
1. Install the plugin
323
-
- go into package.json at the root of the project (most probably push sample) and set the dir to "absolute/path/to/pushpluginrepo"
324
-
325
-
2. Amend build.gradle to include the google-services gradle plugin and apply it
326
-
- open projectRoot/platforms/android/build.gradle
327
-
- find the following piece of code (it's at the top)
328
-
329
-
```groovy
330
-
buildscript {
331
-
repositories {
332
-
jcenter()
333
-
}
334
-
335
-
dependencies {
336
-
classpath "com.android.tools.build:gradle:2.1.2"
337
-
classpath "com.google.gms:google-services:3.0.0" // <<== This line will not be there. Add it.
338
-
}
339
-
}
340
-
```
341
-
342
-
- add | classpath "com.google.gms:google-services:3.0.0" | as a dependency (as shown above)
343
-
- add | apply plugin: "com.google.gms.google-services" | at the very bottom of the file
344
-
345
-
3. google-services.json
346
-
To use FCM, you need this file. It contains configurations and credentials for your Google/Firebase project. To get one...
347
-
348
-
- visit http://firebase.google.com.
349
-
- create a Firebase project or migrate an existing Google project
350
-
- in the project "overview" page click "Add Firebase to your Android app" in the top middle of the page.
351
-
- type in package name (for the push sample project "com.telerik.PushNotificationApp")
352
-
- leave the other fields empty (it's just a test app) and click "Add app" - this will download your google-services.json
353
-
- place the google-services.json file into projectroot/App_Resources/Android
354
-
355
-
If something goes wrong, try this - https://firebase.google.com/docs/android/setup
356
-
357
-
4. The Firebase Server key
358
-
You need a Server key to send messages.
359
-
360
-
- go to the project you created/migrated in 3) "overview" page
361
-
- in the top left of the page (under the Firebase logo), click the gear icon and select "project settings"
362
-
- from the tabs at the top of the newly opened page, click "cloud messaging"
363
-
- copy the "Server key" into the "Push Settings" page of Backend Services as "Google API Key"
364
-
- copy the Sender ID and use it to register with the push plugin (for the push sample app, paste it where it asks for google project number)
365
-
366
-
5. tns run android
367
-
368
-
- test the push plugin
369
-
370
-
371
-
### Things that have changed
372
-
373
-
- When you send a notification through Backend Services, the value of the "Android" key can now have both "data" and "notification" keys.
374
-
- Notification messages are Data, Notification or Mixed
375
-
- The "data" key should function just like before:
376
-
- its "message", "title", "color", "smallIcon", "largeIcon" (etc..) keys should be respected
377
-
- the onMessageReceived callback is called each time a "data" notification is received with the same arguments
378
-
- when in background mode, a notification is created in the tray (otherwise, it is not). tapping that notification launches the app and invokes the onMessageReceived callback with the same arguments
379
-
- The "notification" key is new. It functions like the native FCM implementation... more or less :)
380
-
- notification messages support all FCM key/values
381
-
- if the app is in foreground, it invokes the onMessageReceived callback with arguments (message, dataAsJson) - this may change, according to what you and Dobrev figure out, ask him
382
-
- if the app is in background, a notification is put in the tray. When tapped, it launches the app, but does not invoke the onMessageReceived callback
383
-
- mixed messages are supported. when a mixed message is received and....
384
-
- the app is in foreground, the onMessageReceived callback is invoked with params (message, dataAsJson)
385
-
- the app is in background, the onMessageReceived callback is not invoked
386
-
- the app is in background, and the notification in the tray is tapped, the "data" part of the mixed message is available in the extras of the intent of the launched activity - these can be accessed with through nativescript, like they would in Java
387
-
- we have removed the default large icon because it forced you to have a large icon and this wasnt the behaviour of FCM notifications
388
-
- default color and icon for FCM messages can be set in the AndroidManifest.xml of the project using this XML, inside the "application" tag:
0 commit comments