Use the right method for fcm

This commit is contained in:
QuantumEntangledAndy committed 2023-05-19 16:18:30 +07:00
1 parent f99df6e5e7
commit c3f3ecdb83
4 files changed
+35 -6

No files matched your search

+4 -4
View File
@@ -10,13 +10,13 @@ pub enum PhoneType {
/// Specify that this is an andriod push notfication
///
/// In this case the token must firebase cloud messaging token
Andriod,
Android,
}
impl BcCamera {
/// Convenience method for andriod of `[send_pushinfo]`
pub async fn send_pushinfo_andriod(&self, token: &str, client_id: &str) -> Result<()> {
self.send_pushinfo(token, client_id, PhoneType::Andriod)
pub async fn send_pushinfo_android(&self, token: &str, client_id: &str) -> Result<()> {
self.send_pushinfo(token, client_id, PhoneType::Android)
.await
}
/// Convenience method for andriod of `[send_pushinfo]`
@@ -36,7 +36,7 @@ impl BcCamera {
let phone_type_str = match phone_type {
PhoneType::Ios => "reo_iphone",
PhoneType::Andriod => "reo_fcm",
PhoneType::Android => "reo_fcm",
};
let msg = Bc {
+27
View File
@@ -202,3 +202,30 @@ We can use the
`https://pushx.reolink.com/listeners/<clientID_FROM_PushInfo>/devices`
api to confirm if our client is regeristed for push notifications.
Which was the next thing to do once we passed the token onto the camera
---
On motion reolink will send the following json
```json
{
"data": {
"SRVTIME": "2023-05-19T08:07:03.566Z",
"ALMNAME": "Motion Alert from Cam01",
"sound": "push.wav",
"CHNAME": "Cam0",
"messageType": "alarm",
"DEVNAME": "Cam01",
"pushVersion": "v1.1",
"UID": "REDACTED",
"ALMTYPE": "MD",
"ALMCHN": "1",
"alert": "Motion Alert from Cam01",
"title": "Camera Alert"
},
"from": "743639030586",
"priority": "normal",
"notification": { "title": "Camera Alert", "body": "Motion Alert from Cam01" },
"fcmMessageId": "REDACTED"
}
```
+2 -2
View File
@@ -65,7 +65,7 @@ async fn main() -> Result<()> {
info!("registration.fcm_token: {}", registration.fcm_token);
let uid = "6A5443E486511B0D828543445DC55A7D"; // MD5 Hash of "WHY_REOLINK"
camera
.send_pushinfo_ios(&registration.fcm_token, uid)
.send_pushinfo_android(&registration.fcm_token, uid)
.await?;
info!("Listening");
@@ -75,7 +75,7 @@ async fn main() -> Result<()> {
info!("Message JSON: {}", message.payload_json);
info!("Persistent ID: {:?}", message.persistent_id);
},
vec!["1:696841269229:ios:695029b18debb23e".to_owned()],
vec![],
);
listener.connect().await?;
Ok(())
+2
View File
@@ -149,6 +149,7 @@ local message_types = {
[109]="<Snap>",
[114]="<Uid>",
[115]="<WifiSignal>",
[116]="<Wifi>",
[120]="<OnlineUserList>",
[122]="<PerformanceInfo>",
[123]="<ReplaySeek>",
@@ -162,6 +163,7 @@ local message_types = {
[151]="<AbilityInfo>",
[190]="PTZ Preset",
[194]="<Ftp> (test)",
[195]="<AutoUpdate>",
[199]="<Support>",
[208]="<LedState>",
[209]="<LedState> (write)",