Skip to content
Snippets Groups Projects
Commit 0f8d8914 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Adrien Béraud
Browse files

iOS: drop support for voip notifications

parent b9c79a1d
Branches
Tags
No related merge requests found
......@@ -223,13 +223,6 @@ list (APPEND opendht_SOURCES
src/thread_pool.cpp
)
if (APPLE)
list (APPEND opendht_SOURCES
src/compat/apple/apple_utils.h
src/compat/apple/apple_utils.mm
)
endif()
list (APPEND opendht_HEADERS
include/opendht/def.h
include/opendht/utils.h
......
......@@ -32,7 +32,6 @@ LT_INIT()
LT_LANG(C++)
AC_LANG(C++)
AC_PROG_CXX
AC_PROG_OBJCXX
AX_CXX_COMPILE_STDCXX(17,[noext],[mandatory])
dnl Check for logs
......@@ -92,7 +91,6 @@ case "${host_os}" in
SYS=linux
;;
darwin*)
APPLE=1
SYS=darwin
;;
mingw32*)
......@@ -112,7 +110,6 @@ case "${host_os}" in
;;
esac
AM_CONDITIONAL(APPLE, [test "x$SYS" = "xdarwin"])
AM_CONDITIONAL(WIN32, [test "x$SYS" = "xmingw32"])
AS_IF([test "x$SYS" = "xandroid"],
[], [LDFLAGS="${LDFLAGS} -lpthread"])
......@@ -191,7 +188,6 @@ AM_COND_IF([PROXY_CLIENT_OR_SERVER], [
])
CXXFLAGS="${CXXFLAGS} -DMSGPACK_NO_BOOST -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT"
OBJCXX="$CXX $CXXFLAGS"
AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools],[Disable tools (CLI DHT node)]),,build_tools=yes)
AM_CONDITIONAL(ENABLE_TOOLS, test x$build_tools == xyes)
......
......@@ -40,8 +40,7 @@ namespace dht {
enum class PushType {
None = 0,
Android,
iOS,
iOSLegacy
iOS
};
}
MSGPACK_ADD_ENUM(dht::PushType)
......
......@@ -30,12 +30,6 @@ libopendht_la_SOURCES = \
network_utils.cpp \
thread_pool.cpp
if APPLE
libopendht_la_SOURCES += \
compat/apple/apple_utils.h \
compat/apple/apple_utils.mm
endif
if WIN32
libopendht_la_SOURCES += rng.cpp
endif
......
/*
* Copyright (C) 2014-2022 Savoir-faire Linux Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <string>
namespace dht {
namespace apple_utils {
std::string getPlatformVersion();
}
}
/*
* Copyright (C) 2014-2022 Savoir-faire Linux Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "apple_utils.h"
#ifdef __APPLE__
#include <Foundation/Foundation.h>
#include "TargetConditionals.h"
#endif
namespace dht {
namespace apple_utils {
std::string
getPlatformVersion() {
#ifdef __APPLE__
#if TARGET_OS_IPHONE
if (@available(iOS 14.5, *)) {
return "ios";
}
return "apple";
#elif TARGET_OS_MAC
return "macos";
#endif
#endif
return "";
}
}
} /* dht */
......@@ -22,9 +22,6 @@
#include "dhtrunner.h"
#include "op_cache.h"
#include "utils.h"
#ifdef __APPLE__
#include "compat/apple/apple_utils.h"
#endif
#include <http_parser.h>
#include <deque>
......@@ -1308,7 +1305,7 @@ DhtProxyClient::getPushRequest(Json::Value& body) const
#endif
#ifdef __APPLE__
body["topic"] = notificationTopic_;
body["platform"] = apple_utils::getPlatformVersion();
body["platform"] = "ios";
#endif
}
......
......@@ -756,20 +756,12 @@ DhtProxyServer::getTypeFromString(const std::string& type) {
return PushType::Android;
else if (type == "ios")
return PushType::iOS;
else if (type == "apple")
return PushType::iOSLegacy; // proxy_client is not updated or using ios < 14.5
return PushType::None;
}
std::string
DhtProxyServer::getDefaultTopic(PushType type) {
if (bundleId_.empty())
return {};
if (type == PushType::iOS)
return bundleId_;
else if (type == PushType::iOSLegacy)
return bundleId_ + ".voip";
return {};
return bundleId_;
}
RequestStatus
......@@ -1045,19 +1037,15 @@ DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& jso
notification["expiration"] = exp;
if (!topic.empty())
notification["topic"] = topic;
if (type == PushType::iOS) {
if (highPriority) {
Json::Value alert(Json::objectValue);
alert["title"]="hello";
notification["push_type"] = "alert";
notification["alert"] = alert;
notification["mutable_content"] = true;
} else {
notification["push_type"] = "background";
notification["content_available"] = true;
}
} else if (type == PushType::iOSLegacy) {
notification["push_type"] = "voip";
if (highPriority) {
Json::Value alert(Json::objectValue);
alert["title"]="hello";
notification["push_type"] = "alert";
notification["alert"] = alert;
notification["mutable_content"] = true;
} else {
notification["push_type"] = "background";
notification["content_available"] = true;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment