Skip to content

Commit

Permalink
Add android channel id
Browse files Browse the repository at this point in the history
Add android channel id to app devices
  • Loading branch information
sochs committed Dec 14, 2023
1 parent 9315db5 commit a43f703
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ void API::notificationObj(JsonObject &jObj)
_app["token"] = String(pushApp.devices[i].token);
_app["device_id"] = DeviceId::get();
_app["sound"] = gSystem->notification.getNotificationSound(pushApp.devices[i].sound);
_app["android_channel_id"] = String(pushApp.devices[i].androidchannelid);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ void Notification::saveConfig()
device["id"] = pushApp.devices[i].id;
device["token"] = pushApp.devices[i].token;
device["sound"] = pushApp.devices[i].sound;
device["androidchannelid"] = pushApp.devices[i].androidchannelid;
}
}

Expand Down Expand Up @@ -317,6 +318,11 @@ void Notification::loadConfig()
pushApp.devices[deviceIndex].sound = _device["sound"].as<uint8_t>();
}

if (_device.containsKey("androidchannelid"))
{
strcpy(pushApp.devices[deviceIndex].androidchannelid, _device["androidchannelid"].asString());
}

deviceIndex++;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ typedef struct
char name[31];
char id[65];
char token[255];
char androidchannelid[255];
uint8_t sound;
} PushAppDeviceType;

Expand Down
6 changes: 6 additions & 0 deletions src/WebHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ bool NanoWebHandler::setPush(AsyncWebServerRequest *request, uint8_t *datas)
boolean hasToken = _device.containsKey("token");
boolean hasHashedToken = _device.containsKey("token_sha256");
boolean hasSound = _device.containsKey("sound");
boolean hasAndroidChannelID = _device.containsKey("android_channel_id");

// check length of name and id
if ((strlen(_device["name"].asString()) >= sizeof(PushAppDeviceType::name)) &&
Expand Down Expand Up @@ -900,6 +901,11 @@ bool NanoWebHandler::setPush(AsyncWebServerRequest *request, uint8_t *datas)
app.devices[deviceIndex].sound = _device["sound"].as<uint8_t>();
}

if(hasAndroidChannelID)
{
strcpy(app.devices[deviceIndex].androidchannelid, _device["android_channel_id"].asString());
}

deviceIndex++;
}
}
Expand Down

0 comments on commit a43f703

Please sign in to comment.