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
Copy file name to clipboardExpand all lines: samples/kotlin-android-app/README.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,4 +21,31 @@ The sample app is configured to open links with the schema and hostname `https:/
21
21
Here is how you can do it via adb
22
22
```bash
23
23
adb shell am start -W -a android.intent.action.VIEW -d "https://segment-sample.com?utm_source=cli\&utm_click=2" com.segment.analytics.next
24
-
```
24
+
```
25
+
26
+
## FCM
27
+
This project is setup to track push notification received and opened events. This code is strictly optional and must be customized as per your needs. The code here is only for demonstration purposes
28
+
### Setup
29
+
- Add your FCM project's `google-services.json` to this folder
30
+
- Modify `MyFirebaseService.kt` to customize the notification displayed to the user.
31
+
- Here is how to send a push notification using cURL [this uses the legacy api](https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-using-the-legacy-app-server-protocols)
32
+
```bash
33
+
curl --request POST \
34
+
--url https://fcm.googleapis.com/fcm/send \
35
+
--header 'Authorization: key=<SERVER_KEY>' \
36
+
--header 'Content-Type: application/json' \
37
+
--data '{
38
+
"data": {
39
+
"title": "Hello World"
40
+
"content": "You have mail",
41
+
},
42
+
"to": "<FCM_TOKEN_FOR_DEVICE>"
43
+
}'
44
+
```
45
+
46
+
### How it works
47
+
- We have 2 core changes
48
+
- MyFirebaseService.kt
49
+
The core component to handle FCM push messages. This is responsible for handling the incoming message and assigning the intents for the notification. It is also responsible for firing the `Push Notification Received` event.
50
+
- PushNotificationTracking.kt
51
+
The analytics plugin responsible for firing the "Push Notification Tapped" event. This is a lifecycle plugin that will be invoked for any Activity onCreate.
0 commit comments