Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 49ff5fb

Browse files
author
Boris Tacyniak
authored
Merge pull request #2063 from ambassify/feature/ios-subtitle
feature(ios): Add support for subtitle notification property
2 parents 100e8f4 + 614b451 commit 49ff5fb

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ PushNotification.localNotification({
336336

337337
/* iOS only properties */
338338
category: "", // (optional) default: empty string
339+
subtitle: "My Notification Subtitle", // (optional) smaller title below notification title
339340

340341
/* iOS and Android properties */
341342
id: 0, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID

example/NotifService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,15 @@ export default class NotifService {
8787
ongoing: false, // (optional) set whether this is an "ongoing" notification
8888
actions: ['Yes', 'No'], // (Android only) See the doc for notification actions to know more
8989
invokeApp: true, // (optional) This enable click on actions to bring back the application to foreground or stay in background, default: true
90-
90+
9191
when: null, // (optionnal) Add a timestamp pertaining to the notification (usually the time the event occurred). For apps targeting Build.VERSION_CODES.N and above, this time is not shown anymore by default and must be opted into by using `showWhen`, default: null.
9292
usesChronometer: false, // (optional) Show the `when` field as a stopwatch. Instead of presenting `when` as a timestamp, the notification will show an automatically updating display of the minutes and seconds since when. Useful when showing an elapsed time (like an ongoing phone call), default: false.
9393
timeoutAfter: null, // (optional) Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled, default: null
9494

9595
/* iOS only properties */
9696
category: '', // (optional) default: empty string
97-
97+
subtitle: "My Notification Subtitle", // (optional) smaller title below notification title
98+
9899
/* iOS and Android properties */
99100
id: this.lastId, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
100101
title: 'Local Notification', // (optional)

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,12 @@ Notifications.localNotification = function({...details}) {
170170
soundName = ''; // empty string results in no sound (and no vibration)
171171
}
172172

173-
// for valid fields see: https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html
173+
// for valid fields see: https://github.com/react-native-push-notification-ios/push-notification-ios#addnotificationrequest
174174

175175
this.handler.addNotificationRequest({
176176
id: (!details.id ? Math.floor(Math.random() * Math.pow(2, 32)).toString() : details.id),
177177
title: details.title,
178+
subtitle: details.subtitle,
178179
body: details.message,
179180
badge: details.number,
180181
sound: soundName,
@@ -252,6 +253,7 @@ Notifications.localNotificationSchedule = function({...details}) {
252253
id: (!details.id ? Math.floor(Math.random() * Math.pow(2, 32)).toString() : details.id),
253254
fireDate: details.date.toISOString(),
254255
title: details.title,
256+
subtitle: details.subtitle,
255257
body: details.message,
256258
sound: soundName,
257259
isSilent: details.playSound === false,
@@ -364,6 +366,7 @@ Notifications._transformNotificationObject = function(data, isFromBackground = n
364366
data: notifData,
365367
badge: data.getBadgeCount(),
366368
title: data.getTitle(),
369+
subtitle: data.getSubtitle(),
367370
soundName: data.getSound(),
368371
fireDate: Date.parse(data._fireDate),
369372
action: data.getActionIdentifier(),

0 commit comments

Comments
 (0)