• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rj76 / fcm-rust / 7614069314

22 Jan 2024 04:12PM UTC coverage: 5.2%. Remained the same
7614069314

Pull #4

github

web-flow
Merge 59c8a7a94 into a8babd228
Pull Request #4: feat: build new api

561 of 35893 branches covered (0.0%)

Branch coverage included in aggregate %.

116 of 239 new or added lines in 22 files covered. (48.54%)

1163 existing lines in 58 files now uncovered.

15495 of 272851 relevant lines covered (5.68%)

170.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/android/android_notification.rs
1
use serde::Serialize;
2

3
use super::{
4
    light_settings::{LightSettings, LightSettingsInternal},
5
    notification_priority::NotificationPriority,
6
    visibility::Visibility,
7
};
8

NEW
9
#[derive(Serialize, Debug)]
×
10
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#androidnotification
11
pub(crate) struct AndroidNotificationInternal {
12
    // The notification's title.
13
    #[serde(skip_serializing_if = "Option::is_none")]
14
    title: Option<String>,
15

16
    // The notification's body text.
17
    #[serde(skip_serializing_if = "Option::is_none")]
18
    body: Option<String>,
19

20
    // The notification's icon.
21
    #[serde(skip_serializing_if = "Option::is_none")]
22
    icon: Option<String>,
23

24
    // The notification's icon color, expressed in #rrggbb format.
25
    #[serde(skip_serializing_if = "Option::is_none")]
26
    color: Option<String>,
27

28
    // The sound to play when the device receives the notification.
29
    #[serde(skip_serializing_if = "Option::is_none")]
30
    sound: Option<String>,
31

32
    // Identifier used to replace existing notifications in the notification drawer.
33
    #[serde(skip_serializing_if = "Option::is_none")]
34
    tag: Option<String>,
35

36
    // The action associated with a user click on the notification.
37
    #[serde(skip_serializing_if = "Option::is_none")]
38
    click_action: Option<String>,
39

40
    // The key to the body string in the app's string resources to use to localize the body text to the user's
41
    // current localization.
42
    #[serde(skip_serializing_if = "Option::is_none")]
43
    body_loc_key: Option<String>,
44

45
    // Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the
46
    // body text to the user's current localization.
47
    #[serde(skip_serializing_if = "Option::is_none")]
48
    body_loc_args: Option<Vec<String>>,
49

50
    // The key to the title string in the app's string resources to use to localize the title text to the user's
51
    // current localization.
52
    #[serde(skip_serializing_if = "Option::is_none")]
53
    title_loc_key: Option<String>,
54

55
    // Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the
56
    // title text to the user's current localization.
57
    #[serde(skip_serializing_if = "Option::is_none")]
58
    title_loc_args: Option<Vec<String>>,
59

60
    // The notification's channel id (new in Android O).
61
    #[serde(skip_serializing_if = "Option::is_none")]
62
    channel_id: Option<String>,
63

64
    // Sets the "ticker" text, which is sent to accessibility services.
65
    #[serde(skip_serializing_if = "Option::is_none")]
66
    ticker: Option<String>,
67

68
    // When set to false or unset, the notification is automatically dismissed when the user clicks it in the panel.
69
    #[serde(skip_serializing_if = "Option::is_none")]
70
    sticky: Option<bool>,
71

72
    // Set the time that the event in the notification occurred. Notifications in the panel are sorted by this time.
73
    // Timestamp format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Timestamp
74
    #[serde(skip_serializing_if = "Option::is_none")]
75
    event_time: Option<String>,
76

77
    // Set whether or not this notification is relevant only to the current device.
78
    #[serde(skip_serializing_if = "Option::is_none")]
79
    local_only: Option<bool>,
80

81
    // Set the relative priority for this notification.
82
    #[serde(skip_serializing_if = "Option::is_none")]
83
    notification_priority: Option<NotificationPriority>,
84

85
    // If set to true, use the Android framework's default sound for the notification.
86
    #[serde(skip_serializing_if = "Option::is_none")]
87
    default_sound: Option<bool>,
88

89
    // If set to true, use the Android framework's default vibrate pattern for the notification.
90
    #[serde(skip_serializing_if = "Option::is_none")]
91
    default_vibrate_timings: Option<bool>,
92

93
    // If set to true, use the Android framework's default LED light settings for the notification.
94
    #[serde(skip_serializing_if = "Option::is_none")]
95
    default_light_settings: Option<bool>,
96

97
    // Set the vibration pattern to use
98
    // Duration format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Duration
99
    #[serde(skip_serializing_if = "Option::is_none")]
100
    vibrate_timings: Option<Vec<String>>,
101

102
    // Set the Notification.visibility of the notification.
103
    #[serde(skip_serializing_if = "Option::is_none")]
104
    visibility: Option<Visibility>,
105

106
    // Sets the number of items this notification represents.
107
    #[serde(skip_serializing_if = "Option::is_none")]
108
    notification_count: Option<i32>,
109

110
    // Settings to control the notification's LED blinking rate and color if LED is available on the device.
111
    #[serde(skip_serializing_if = "Option::is_none")]
112
    light_settings: Option<LightSettingsInternal>,
113

114
    // Contains the URL of an image that is going to be displayed in a notification.
115
    #[serde(skip_serializing_if = "Option::is_none")]
116
    image: Option<String>,
117
}
118

NEW
119
#[derive(Debug, Default)]
×
120
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#androidnotification
121
pub struct AndroidNotification {
122
    // The notification's title.
NEW
123
    pub title: Option<String>,
×
124

125
    // The notification's body text.
NEW
126
    pub body: Option<String>,
×
127

128
    // The notification's icon.
NEW
129
    pub icon: Option<String>,
×
130

131
    // The notification's icon color, expressed in #rrggbb format.
NEW
132
    pub color: Option<String>,
×
133

134
    // The sound to play when the device receives the notification.
NEW
135
    pub sound: Option<String>,
×
136

137
    // Identifier used to replace existing notifications in the notification drawer.
NEW
138
    pub tag: Option<String>,
×
139

140
    // The action associated with a user click on the notification.
NEW
141
    pub click_action: Option<String>,
×
142

143
    // The key to the body string in the app's string resources to use to localize the body text to the user's
144
    // current localization.
NEW
145
    pub body_loc_key: Option<String>,
×
146

147
    // Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the
148
    // body text to the user's current localization.
NEW
149
    pub body_loc_args: Option<Vec<String>>,
×
150

151
    // The key to the title string in the app's string resources to use to localize the title text to the user's
152
    // current localization.
NEW
153
    pub title_loc_key: Option<String>,
×
154

155
    // Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the
156
    // title text to the user's current localization.
NEW
157
    pub title_loc_args: Option<Vec<String>>,
×
158

159
    // The notification's channel id (new in Android O).
NEW
160
    pub channel_id: Option<String>,
×
161

162
    // Sets the "ticker" text, which is sent to accessibility services.
NEW
163
    pub ticker: Option<String>,
×
164

165
    // When set to false or unset, the notification is automatically dismissed when the user clicks it in the panel.
NEW
166
    pub sticky: Option<bool>,
×
167

168
    // Set the time that the event in the notification occurred. Notifications in the panel are sorted by this time.
169
    // Timestamp format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Timestamp
NEW
170
    pub event_time: Option<String>,
×
171

172
    // Set whether or not this notification is relevant only to the current device.
NEW
173
    pub local_only: Option<bool>,
×
174

175
    // Set the relative priority for this notification.
NEW
176
    pub notification_priority: Option<NotificationPriority>,
×
177

178
    // If set to true, use the Android framework's default sound for the notification.
NEW
179
    pub default_sound: Option<bool>,
×
180

181
    // If set to true, use the Android framework's default vibrate pattern for the notification.
NEW
182
    pub default_vibrate_timings: Option<bool>,
×
183

184
    // If set to true, use the Android framework's default LED light settings for the notification.
NEW
185
    pub default_light_settings: Option<bool>,
×
186

187
    // Set the vibration pattern to use
188
    // Duration format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Duration
NEW
189
    pub vibrate_timings: Option<Vec<String>>,
×
190

191
    // Set the Notification.visibility of the notification.
NEW
192
    pub visibility: Option<Visibility>,
×
193

194
    // Sets the number of items this notification represents.
NEW
195
    pub notification_count: Option<i32>,
×
196

197
    // Settings to control the notification's LED blinking rate and color if LED is available on the device.
NEW
198
    pub light_settings: Option<LightSettings>,
×
199

200
    // Contains the URL of an image that is going to be displayed in a notification.
NEW
201
    pub image: Option<String>,
×
202
}
203

204
impl AndroidNotification {
205
    pub(crate) fn finalize(self) -> AndroidNotificationInternal {
206
        AndroidNotificationInternal {
207
            title: self.title,
208
            body: self.body,
209
            icon: self.icon,
210
            color: self.color,
211
            sound: self.sound,
212
            tag: self.tag,
213
            click_action: self.click_action,
214
            body_loc_key: self.body_loc_key,
215
            body_loc_args: self.body_loc_args,
216
            title_loc_key: self.title_loc_key,
217
            title_loc_args: self.title_loc_args,
218
            channel_id: self.channel_id,
219
            ticker: self.ticker,
220
            sticky: self.sticky,
221
            event_time: self.event_time,
222
            local_only: self.local_only,
223
            notification_priority: self.notification_priority,
224
            default_sound: self.default_sound,
225
            default_vibrate_timings: self.default_vibrate_timings,
226
            default_light_settings: self.default_light_settings,
227
            vibrate_timings: self.vibrate_timings,
228
            visibility: self.visibility,
229
            notification_count: self.notification_count,
230
            light_settings: self.light_settings.map(|x| x.finalize()),
231
            image: self.image,
232
        }
233
    }
234
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc