setChannelPushSound static method
Implementation
static Future<TPChannel?> setChannelPushSound(
TPChannel tpChannel,
String sound,
{
Function(int? errorCode, String? errorMessage)? errorCallback
}) async
{
if (!_isInitialized(errorCallback: errorCallback)) { return null; }
if (!_checkAuthInfo(errorCallback: errorCallback)) { return null; }
try {
Map<String, dynamic> body = Map.from({});
if (Platform.isAndroid) {
body["pushNotificationSoundAos"] = sound;
} else if (Platform.isIOS) {
body["pushNotificationSoundIos"] = sound;
} else {
body["pushNotificationSoundUnknown"] = sound;
}
String url = "/channels/${tpChannel.getChannelId()}/push/settings";
Map<String, dynamic> response = await HttpUtil.postJson(url, body);
Map<String, dynamic> channelMap = response["channel"];
return TPChannel(channelMap);
} on TPException catch(e) {
Logger.log("$e");
if(errorCallback != null) { errorCallback(e.getCode(), e.getMessage()); }
} catch(e){
Logger.log("$e");
if(errorCallback != null) { errorCallback(-1, e.toString()); }
}
return null;
}