Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/com/kinoroy/expo/push/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public final class Message {

private String channelId;

private String subtitle;

private Message() {}

/**
Expand Down Expand Up @@ -111,6 +113,13 @@ public Integer getBadge() {
public String getChannelId() {
return channelId;
}
/**
* @return The subtitle to display in the notification below the title.
* This currently only affects iOS.
*/
public String getSubtitle() {
return subtitle;
}

/**
* A class to help contruct messages
Expand All @@ -137,6 +146,8 @@ public static class Builder {

private String channelId;

private String subtitle;

/**
* @param to A token of the form ExponentPushToken[xxxxxxx]
*/
Expand Down Expand Up @@ -228,6 +239,15 @@ public Builder channelId(String channelId) {
return this;
}

/**
* The subtitle to display in the notification below the title.
* This currently only affects iOS.
*/
public Builder subtitle(String subtitle) {
this.subtitle = subtitle;
return this;
}

public Message build() {
Message message = new Message();

Expand All @@ -250,6 +270,7 @@ public Message build() {
}
message.badge = badge;
message.channelId = channelId;
message.subtitle = subtitle;

return message;
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/kinoroy/expo/push/TestModels.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void testSerializeMessage() throws Exception {
.expiration(Instant.ofEpochSecond(1540145105))
.ttl(Duration.ofDays(1))
.sound("mySound.wav")
.subtitle("This is an iOS subtitle")
.build();

String loadedJson = readFromFile("testMessage.json");
Expand All @@ -56,6 +57,7 @@ public void testSerializeMessage() throws Exception {
assertEquals(message.getExpiration(), loadedMessage.getExpiration());
assertEquals(message.getTtl(), loadedMessage.getTtl());
assertEquals(message.getSound(), loadedMessage.getSound());
assertEquals(message.getSubtitle(), loadedMessage.getSubtitle());


}
Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/com/kinoroy/expo/push/testMessage.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@

"badge": 11,

"channelId": "abc"
"channelId": "abc",

"subtitle": "This is an iOS subtitle"
}