Skip to content

Commit e86affa

Browse files
authored
Merge pull request #159 from hansemannn/androidFields
feat(android): add notification fields to fcm_data
2 parents 8a84a33 + ca621bf commit e86affa

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

android/manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# during compilation, packaging, distribution, etc.
44
#
55

6-
version: 3.4.2
6+
version: 3.4.3
77
apiversion: 4
88
architectures: arm64-v8a armeabi-v7a x86 x86_64
99
description: titanium-firebase-cloud-messaging

android/src/firebase/cloudmessaging/TiFirebaseMessagingService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ private Boolean showNotification(RemoteMessage remoteMessage) {
181181
editor.putString("titanium.firebase.cloudmessaging.message", jsonData.toString());
182182
editor.commit();
183183

184+
try {
185+
// adding normal notification fields to the fcm_data node
186+
if (!remoteMessage.getNotification().getTitle().isEmpty()) {
187+
jsonData.put("notification_title", remoteMessage.getNotification().getTitle());
188+
}
189+
if (!remoteMessage.getNotification().getBody().isEmpty()) {
190+
jsonData.put("notification_body", remoteMessage.getNotification().getBody());
191+
}
192+
} catch (Exception ex) {
193+
Log.e(TAG, "Error adding fields: " + ex.getMessage());
194+
}
195+
184196
if (!showNotification) {
185197
// hidden notification - still send broadcast with data for next app start
186198
Intent i = new Intent();

0 commit comments

Comments
 (0)