Alejandro Pérez Bueno Jan 16, 2024
In this exercise we had to enable Firebase Cloud Messaging and integrate it on our app. To do this we had to do the following:
- Obtain the token.
- Create the notification.
- Send it to the phone using the obtained token.
- Receive it on the device while the app is in the background.
See Figure 1 to see how the notification appears on the end device
Tip
For this CAT I used a real phone connected through ADB, as it was more convenient than using an Android VM.
Note
Answered in Project Folder (see
MainActivity.kt
).
In the second exercise we had to extend the previous integration and also load an alert upon clicking the notification.
See Figure 2 for details on how the notification arrives, and how the alert looks upon clicking on the notification.
Note
Answered in Project Folder (see
MainActivity.kt
).
For this one, we had to override the default onMessageReceived
function to implement a new alert, this time it will receive remote
notifications when the app is open, but will display them as an alert
instead of as a notification.
Check Figure 3 to see an alert in action.
Note
Answered in Project Folder (see
MainActivity.kt
andMyFirebaseMessagingService.kt
).
The last exercise implements basic geolocation support in our app. To implement it, we followed the following logic:
- Check if the location permission has been granted, if not request the user to grant it.
- Attempt to determine a location using on Google Play Services.
- Once a location is found, a toast message appears with the format
“
latitude, longitude
” and a pop-up (also called heads-up) notification appears with the text “Start Track
”.
Check Figure 4 for more details.
Note
Answered in Project Folder (see
MainActivity.kt
).
Figure 2: Test alert upon opening notification