Skip to content

Commit

Permalink
fix: check if intent comes from FCM
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgerardojacinto committed Dec 13, 2023
1 parent 9ea4058 commit 354d91a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

The changes documented here do not include those from the original repository.

## [Version 2.0.1]
- Fix: Only deal with intents from the plugin (https://outsystemsrd.atlassian.net/browse/RMET-3013)

## [Version 2.0.0]
- Feat: update sound hook to unzip sound files, for both iOS and Android (https://outsystemsrd.atlassian.net/browse/RMET-2464).
- Feat: update firebase core version (https://outsystemsrd.atlassian.net/browse/RMET-2451).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.outsystems.firebase.cloudmessaging",
"version": "2.0.0",
"version": "2.0.1",
"description": "Outsystems plugin for Firebase Cloud Messaging",
"keywords": [
"ecosystem:cordova",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin id="com.outsystems.firebase.cloudmessaging" version="2.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="com.outsystems.firebase.cloudmessaging" version="2.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>OSFirebaseCloudMessaging</name>
<description>Outsystems plugin for Firebase Cloud Messaging</description>
<author>OutSystems Inc</author>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class OSFirebaseCloudMessaging : CordovaImplementation() {
private const val ERROR_FORMAT_PREFIX = "OS-PLUG-FCMS-"
private const val NOTIFICATION_PERMISSION_REQUEST_CODE = 123123
private const val NOTIFICATION_PERMISSION_SEND_LOCAL_REQUEST_CODE = 987987
const val FCM_EXPLICIT_NOTIFICATION = "com.outsystems.fcm.notification"
const val GOOGLE_MESSAGE_ID = "google.message_id"
}

override fun initialize(cordova: CordovaInterface, webView: CordovaWebView) {
Expand All @@ -60,8 +62,18 @@ class OSFirebaseCloudMessaging : CordovaImplementation() {
private fun handleIntent(intent: Intent) {
val extras = intent.extras
val extrasSize = extras?.size() ?: 0

// Check if intent comes from an FCM notification. If not, we don't want to handle it
// This is necessary so that we don't mistakenly deal with deep links thinking they're FCM notification clicks
val googleMessageId = extras?.getString(GOOGLE_MESSAGE_ID) // for notifications automatically delivered by the FCM SDK
val fcmInternal = extras?.getString(FCM_EXPLICIT_NOTIFICATION) // for notifications that we explicitly deliver in the FCM plugin

if (googleMessageId.isNullOrEmpty() && fcmInternal.isNullOrEmpty()) {
return
}

if(extrasSize > 0) {
val scheme = extras?.getString(FirebaseMessagingOnActionClickActivity.ACTION_DEEP_LINK_SCHEME)
val scheme = extras.getString(FirebaseMessagingOnActionClickActivity.ACTION_DEEP_LINK_SCHEME)
if (scheme.isNullOrEmpty()) {
FirebaseMessagingOnClickActivity.notifyClickNotification(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ apply plugin: 'kotlin-kapt'
dependencies {
implementation("com.github.outsystems:oscore-android:1.2.0@aar")
implementation("com.github.outsystems:oscordova-android:1.2.0@aar")
implementation("com.github.outsystems:osfirebasemessaging-android:1.1.3@aar")
implementation("com.github.outsystems:osfirebasemessaging-android:1.1.5@aar")
implementation("com.github.outsystems:oslocalnotifications-android:1.0.0@aar")
implementation("com.github.outsystems:osnotificationpermissions-android:0.0.4@aar")

Expand Down

0 comments on commit 354d91a

Please sign in to comment.