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

rj76 / fcm-rust / 7409905236

04 Jan 2024 01:04PM UTC coverage: 5.07%. First build
7409905236

push

github

rj76
Merge branch 'develop' of github.com:rj76/fcm-rust into develop

697 of 36415 branches covered (0.0%)

Branch coverage included in aggregate %.

7 of 20 new or added lines in 8 files covered. (35.0%)

15434 of 281726 relevant lines covered (5.48%)

163.76 hits per line

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

0.0
/src/android/mod.rs
1
use serde::Serialize;
2
use serde_json::Value;
3

4
#[derive(Serialize, Debug)]
×
5
//https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#androidconfig
6
pub struct AndroidConfig {
7
    // An identifier of a group of messages that can be collapsed, so that only the last message gets
8
    // sent when delivery can be resumed.
9
    #[serde(skip_serializing_if = "Option::is_none")]
10
    collapse_key: Option<String>,
×
11

12
    // Message priority.
13
    #[serde(skip_serializing_if = "Option::is_none")]
14
    priority: Option<AndroidMessagePriority>,
×
15

16
    // How long (in seconds) the message should be kept in FCM storage if the device is offline.
17
    // Duration format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Duration
18
    #[serde(skip_serializing_if = "Option::is_none")]
19
    ttl: Option<String>,
×
20

21
    // Package name of the application where the registration token must match in order to receive the message.
22
    #[serde(skip_serializing_if = "Option::is_none")]
23
    restricted_package_name: Option<String>,
×
24

25
    // Arbitrary key/value payload.
26
    #[serde(skip_serializing_if = "Option::is_none")]
27
    data: Option<Value>,
×
28

29
    // Notification to send to android devices.
30
    #[serde(skip_serializing_if = "Option::is_none")]
31
    notification: Option<AndroidNotification>,
32

33
    // Options for features provided by the FCM SDK for Android.
34
    #[serde(skip_serializing_if = "Option::is_none")]
35
    fcm_options: Option<AndroidFcmOptions>,
×
36

37
    // If set to true, messages will be allowed to be delivered to the app while the device is in direct boot mode.
38
    #[serde(skip_serializing_if = "Option::is_none")]
NEW
39
    direct_boot_ok: Option<bool>,
×
40
}
41

42
#[derive(Serialize, Debug)]
×
43
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#Color
44
pub struct Color {
45
    // The amount of red in the color as a value in the interval [0, 1].
46
    red: f32,
47

48
    // The amount of green in the color as a value in the interval [0, 1].
49
    green: f32,
×
50

51
    // The amount of blue in the color as a value in the interval [0, 1].
52
    blue: f32,
×
53

54
    // The fraction of this color that should be applied to the pixel.
NEW
55
    alpha: f32,
×
56
}
57

58
#[derive(Serialize, Debug)]
×
59
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#LightSettings
60
pub struct LightSettings {
61
    // Set color of the LED with google.type.Color.
62
    color: Color,
×
63

64
    // Along with light_off_duration, define the blink rate of LED flashes
65
    // Duration format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Duration
66
    light_on_duration: String,
67

68
    // Along with light_on_duration, define the blink rate of LED flashes.
69
    // Duration format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Duration
70
    light_off_duration: String,
×
71
}
72

73
#[derive(Serialize, Debug)]
×
74
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#androidnotification
75
pub struct AndroidNotification {
76
    // The notification's title.
77
    #[serde(skip_serializing_if = "Option::is_none")]
78
    title: Option<String>,
×
79

80
    // The notification's body text.
81
    #[serde(skip_serializing_if = "Option::is_none")]
82
    body: Option<String>,
×
83

84
    // The notification's icon.
85
    #[serde(skip_serializing_if = "Option::is_none")]
86
    icon: Option<String>,
×
87

88
    // The notification's icon color, expressed in #rrggbb format.
89
    #[serde(skip_serializing_if = "Option::is_none")]
90
    color: Option<String>,
×
91

92
    // The sound to play when the device receives the notification.
93
    #[serde(skip_serializing_if = "Option::is_none")]
94
    sound: Option<String>,
×
95

96
    // Identifier used to replace existing notifications in the notification drawer.
97
    #[serde(skip_serializing_if = "Option::is_none")]
98
    tag: Option<String>,
×
99

100
    // The action associated with a user click on the notification.
101
    #[serde(skip_serializing_if = "Option::is_none")]
102
    click_action: Option<String>,
×
103

104
    // The key to the body string in the app's string resources to use to localize the body text to the user's
105
    // current localization.
106
    #[serde(skip_serializing_if = "Option::is_none")]
107
    body_loc_key: Option<String>,
×
108

109
    // Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the
110
    // body text to the user's current localization.
111
    #[serde(skip_serializing_if = "Option::is_none")]
112
    body_loc_args: Option<Vec<String>>,
×
113

114
    // The key to the title string in the app's string resources to use to localize the title text to the user's
115
    // current localization.
116
    #[serde(skip_serializing_if = "Option::is_none")]
117
    title_loc_key: Option<String>,
×
118

119
    // Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the
120
    // title text to the user's current localization.
121
    #[serde(skip_serializing_if = "Option::is_none")]
122
    title_loc_args: Option<Vec<String>>,
×
123

124
    // The notification's channel id (new in Android O).
125
    #[serde(skip_serializing_if = "Option::is_none")]
126
    channel_id: Option<String>,
×
127

128
    // Sets the "ticker" text, which is sent to accessibility services.
129
    #[serde(skip_serializing_if = "Option::is_none")]
130
    ticker: Option<String>,
×
131

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

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

141
    // Set whether or not this notification is relevant only to the current device.
142
    #[serde(skip_serializing_if = "Option::is_none")]
143
    local_only: Option<bool>,
×
144

145
    // Set the relative priority for this notification.
146
    #[serde(skip_serializing_if = "Option::is_none")]
147
    notification_priority: Option<NotificationPriority>,
×
148

149
    // If set to true, use the Android framework's default sound for the notification.
150
    #[serde(skip_serializing_if = "Option::is_none")]
151
    default_sound: Option<bool>,
×
152

153
    // If set to true, use the Android framework's default vibrate pattern for the notification.
154
    #[serde(skip_serializing_if = "Option::is_none")]
155
    default_vibrate_timings: Option<bool>,
×
156

157
    // If set to true, use the Android framework's default LED light settings for the notification.
158
    #[serde(skip_serializing_if = "Option::is_none")]
159
    default_light_settings: Option<bool>,
×
160

161
    // Set the vibration pattern to use
162
    // Duration format: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?authuser=0#google.protobuf.Duration
163
    #[serde(skip_serializing_if = "Option::is_none")]
164
    vibrate_timings: Option<Vec<String>>,
×
165

166
    // Set the Notification.visibility of the notification.
167
    #[serde(skip_serializing_if = "Option::is_none")]
168
    visibility: Option<Visibility>,
×
169

170
    // Sets the number of items this notification represents.
171
    #[serde(skip_serializing_if = "Option::is_none")]
172
    notification_count: Option<i32>,
173

174
    // Settings to control the notification's LED blinking rate and color if LED is available on the device.
175
    #[serde(skip_serializing_if = "Option::is_none")]
176
    light_settings: Option<LightSettings>,
×
177

178
    // Contains the URL of an image that is going to be displayed in a notification.
179
    #[serde(skip_serializing_if = "Option::is_none")]
180
    image: Option<String>,
×
181
}
182

183
#[derive(Serialize, Debug)]
×
184
//https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#androidconfig
185
pub struct AndroidFcmOptions {
186
    // Label associated with the message's analytics data.
NEW
187
    analytics_label: String,
×
188
}
189

190
#[allow(dead_code)]
191
#[derive(Serialize, Debug)]
×
192
#[serde(rename_all = "UPPERCASE")]
193
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#androidmessagepriority
194
pub enum AndroidMessagePriority {
195
    Normal,
196
    High,
197
}
198

199
#[allow(dead_code)]
200
#[derive(Serialize, Debug)]
×
201
#[serde(rename_all = "UPPERCASE")]
202
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#notificationpriority
203
pub enum NotificationPriority {
204
    PriorityUnspecified,
205
    PriorityMin,
206
    PriorityLow,
207
    PriorityDefault,
208
    PriorityHigh,
209
    PriorityMax,
210
}
211

212
#[allow(dead_code)]
213
#[derive(Serialize, Debug)]
×
214
#[serde(rename_all = "UPPERCASE")]
215
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#visibility
216
pub enum Visibility {
217
    VisibilityUnspecified,
218
    Private,
219
    Public,
220
    Secret,
221
}
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