enableChannelPushNotification static method

Future<TPChannel?> enableChannelPushNotification(
  1. TPChannel tpChannel, {
  2. dynamic errorCallback(
    1. int? errorCode,
    2. String? errorMessage
    )?,
})

Implementation

static Future<TPChannel?> enableChannelPushNotification(
    TPChannel tpChannel,
    {
      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({});
    String url = "/channels/${tpChannel.getChannelId()}/push/enable";
    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;
}