From 01c57fa483d6b11ff785f0a0cd4149fc6088d0af Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 21 Dec 2019 01:30:01 +0800 Subject: [PATCH] Add link helper for iOS --- lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h | 1 + lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm | 7 +++++++ src/online/link_helper.cpp | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h index 21f1fef8c..42fb9efe4 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h @@ -121,6 +121,7 @@ namespace irr m_right_padding = right; } static std::string getSystemLanguageCode(); + static void openURLiOS(const char* url); virtual s32 getTopPadding() { return m_top_padding * m_native_scale; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm index c89c9a53a..254aba426 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm @@ -950,6 +950,13 @@ namespace irr NSString* language = [[NSLocale preferredLanguages] firstObject]; return std::string([language UTF8String]); } + void CIrrDeviceiOS::openURLiOS(const char* url) + { + UIApplication* application = [UIApplication sharedApplication]; + NSString* url_nsstring = [NSString stringWithCString:url encoding:NSUTF8StringEncoding]; + NSURL* nsurl_val = [NSURL URLWithString:url_nsstring]; + [application openURL:nsurl_val]; + } } #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ diff --git a/src/online/link_helper.cpp b/src/online/link_helper.cpp index 9a7fd04ea..804c80c4c 100644 --- a/src/online/link_helper.cpp +++ b/src/online/link_helper.cpp @@ -27,6 +27,10 @@ #include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h" #endif +#ifdef IOS_STK +#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h" +#endif + using namespace Online; namespace Online @@ -48,7 +52,9 @@ namespace Online android->openURL(url); #elif defined(_WIN32) ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); -#elif defined(__APPLE__) && !defined(IOS_STK) +#elif defined(IOS_STK) + irr::CIrrDeviceiOS::openURLiOS(url.c_str()); +#elif defined(__APPLE__) std::string command = std::string("open ").append(url); if (system(command.c_str())) {