Skip to content

Commit 5fb308b

Browse files
committed
feat(fcm): Add support for restricted satellite API
1 parent d69dcbd commit 5fb308b

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

src/main/java/com/google/firebase/messaging/AndroidConfig.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public class AndroidConfig {
5858
@Key("bandwidth_constrained_ok")
5959
private final Boolean bandwidthConstrainedOk;
6060

61+
@Key("restricted_satellite_ok")
62+
private final Boolean restrictedSatelliteOk;
63+
6164
private AndroidConfig(Builder builder) {
6265
this.collapseKey = builder.collapseKey;
6366
if (builder.priority != null) {
@@ -83,6 +86,7 @@ private AndroidConfig(Builder builder) {
8386
this.fcmOptions = builder.fcmOptions;
8487
this.directBootOk = builder.directBootOk;
8588
this.bandwidthConstrainedOk = builder.bandwidthConstrainedOk;
89+
this.restrictedSatelliteOk = builder.restrictedSatelliteOk;
8690
}
8791

8892
/**
@@ -113,6 +117,7 @@ public static class Builder {
113117
private AndroidFcmOptions fcmOptions;
114118
private Boolean directBootOk;
115119
private Boolean bandwidthConstrainedOk;
120+
private Boolean restrictedSatelliteOk;
116121

117122
private Builder() {}
118123

@@ -224,14 +229,23 @@ public Builder setDirectBootOk(boolean directBootOk) {
224229
}
225230

226231
/**
227-
* Sets the {@code bandwidth_constrained_ok} flag. If set to true, messages can be delivered
228-
* even when the device is connected through a bandwidth-constrained network.
232+
* Sets the {@code bandwidth_constrained_ok} flag. If set to true, messages will be allowed
233+
* to be delivered to the app while the device is on a bandwidth constrained network.
229234
*/
230235
public Builder setBandwidthConstrainedOk(boolean bandwidthConstrainedOk) {
231236
this.bandwidthConstrainedOk = bandwidthConstrainedOk;
232237
return this;
233238
}
234239

240+
/**
241+
* Sets the {@code restricted_satellite_ok} flag. If set to true, messages will be allowed
242+
* to be delivered to the app while the device is on a restricted satellite network.
243+
*/
244+
public Builder setRestrictedSatelliteOk(boolean restrictedSatelliteOk) {
245+
this.restrictedSatelliteOk = restrictedSatelliteOk;
246+
return this;
247+
}
248+
235249
/**
236250
* Creates a new {@link AndroidConfig} instance from the parameters set on this builder.
237251
*

src/test/java/com/google/firebase/messaging/MessageTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.junit.Assert.assertSame;
2121
import static org.junit.Assert.fail;
2222

23-
import com.google.api.client.googleapis.util.Utils;
2423
import com.google.api.client.json.JsonFactory;
2524
import com.google.api.client.json.JsonParser;
2625
import com.google.common.collect.ImmutableList;
@@ -247,6 +246,29 @@ public void testAndroidMessageWithBandwidthConstrainedOk() throws IOException {
247246
assertJsonEquals(ImmutableMap.of("topic", "test-topic", "android", data), message);
248247
}
249248

249+
@Test
250+
public void testAndroidMessageWithRestrictedSatelliteOk() throws IOException {
251+
Message message = Message.builder()
252+
.setAndroidConfig(AndroidConfig.builder()
253+
.setRestrictedSatelliteOk(true)
254+
.setNotification(AndroidNotification.builder()
255+
.setTitle("android-title")
256+
.setBody("android-body")
257+
.build())
258+
.build())
259+
.setTopic("test-topic")
260+
.build();
261+
Map<String, Object> notification = ImmutableMap.<String, Object>builder()
262+
.put("title", "android-title")
263+
.put("body", "android-body")
264+
.build();
265+
Map<String, Object> data = ImmutableMap.of(
266+
"restricted_satellite_ok", true,
267+
"notification", notification
268+
);
269+
assertJsonEquals(ImmutableMap.of("topic", "test-topic", "android", data), message);
270+
}
271+
250272
@Test(expected = IllegalArgumentException.class)
251273
public void testAndroidNotificationWithNegativeCount() throws IllegalArgumentException {
252274
AndroidNotification.builder().setNotificationCount(-1).build();
@@ -991,7 +1013,7 @@ public void testExtendedAndroidNotificationParameters() throws IOException {
9911013
}
9921014

9931015
private static void assertJsonEquals(
994-
Map expected, Object actual) throws IOException {
1016+
Map<String, Object> expected, Object actual) throws IOException {
9951017
assertEquals(expected, toMap(actual));
9961018
}
9971019

0 commit comments

Comments
 (0)