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

rj76 / fcm-rust / 8128893026

03 Mar 2024 08:21AM UTC coverage: 5.216% (+0.02%) from 5.2%
8128893026

Pull #4

github

web-flow
Merge 2128a958a into a8babd228
Pull Request #4: feat: build new api

621 of 32863 branches covered (1.89%)

Branch coverage included in aggregate %.

108 of 396 new or added lines in 21 files covered. (27.27%)

252 existing lines in 48 files now uncovered.

15129 of 269097 relevant lines covered (5.62%)

202.27 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")]
NEW
18
    body: Option<String>,
×
19

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

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

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

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

36
    /// The action associated with a user click on the notification.
37
    #[serde(skip_serializing_if = "Option::is_none")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
79
    local_only: Option<bool>,
×
80

81
    /// Set the relative priority for this notification.
82
    #[serde(skip_serializing_if = "Option::is_none")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
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")]
NEW
100
    vibrate_timings: Option<Vec<String>>,
×
101

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

106
    /// Sets the number of items this notification represents.
107
    #[serde(skip_serializing_if = "Option::is_none")]
NEW
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")]
NEW
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")]
NEW
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 {
NEW
205
    pub(crate) fn finalize(self) -> AndroidNotificationInternal {
×
NEW
206
        AndroidNotificationInternal {
×
NEW
207
            title: self.title,
×
NEW
208
            body: self.body,
×
NEW
209
            icon: self.icon,
×
NEW
210
            color: self.color,
×
NEW
211
            sound: self.sound,
×
NEW
212
            tag: self.tag,
×
NEW
213
            click_action: self.click_action,
×
NEW
214
            body_loc_key: self.body_loc_key,
×
NEW
215
            body_loc_args: self.body_loc_args,
×
NEW
216
            title_loc_key: self.title_loc_key,
×
NEW
217
            title_loc_args: self.title_loc_args,
×
NEW
218
            channel_id: self.channel_id,
×
NEW
219
            ticker: self.ticker,
×
NEW
220
            sticky: self.sticky,
×
NEW
221
            event_time: self.event_time,
×
NEW
222
            local_only: self.local_only,
×
NEW
223
            notification_priority: self.notification_priority,
×
NEW
224
            default_sound: self.default_sound,
×
NEW
225
            default_vibrate_timings: self.default_vibrate_timings,
×
NEW
226
            default_light_settings: self.default_light_settings,
×
NEW
227
            vibrate_timings: self.vibrate_timings,
×
NEW
228
            visibility: self.visibility,
×
NEW
229
            notification_count: self.notification_count,
×
NEW
230
            light_settings: self.light_settings.map(|x| x.finalize()),
×
NEW
231
            image: self.image,
×
232
        }
NEW
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

© 2025 Coveralls, Inc