From 5ae613e53b8e82e86d3fe8149f5cde2a720d7978 Mon Sep 17 00:00:00 2001 From: offtkp Date: Sun, 17 Dec 2023 01:39:31 +0200 Subject: [PATCH] [Cloud]iOS support --- CMakeLists.txt | 5 ----- src/cloud.cpp | 4 +++- src/ios_support.h | 1 + src/ios_support.m | 5 +++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39e385565..be6acff48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,8 +190,6 @@ set(SOKOL_HEADERS if(ANDROID) add_definitions(-DSE_PLATFORM_ANDROID) set(LINK_LIBS ${LINK_LIBS} GLESv3 EGL OpenSLES log android) - # link_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/android/${ANDROID_ABI}) - # include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/android/include) message("Android Build!") endif() if(MACOS OR IOS) @@ -299,9 +297,6 @@ endif() if(IOS) set(SKYEMU_SRC ${SKYEMU_SRC} src/ios_support.m) add_definitions(-DSE_PLATFORM_IOS) - # set(LINK_LIBS ${LINK_LIBS} curl z) - # link_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/iOS) - # include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/curl-mobile/iOS/include) endif() if(WIN32) diff --git a/src/cloud.cpp b/src/cloud.cpp index e8de45fd9..1dbd79602 100644 --- a/src/cloud.cpp +++ b/src/cloud.cpp @@ -650,7 +650,7 @@ void cloud_drive_authenticate(cloud_drive_t* drive) { #ifdef EMSCRIPTEN return em_oath_sign_in(drive, GOOGLE_CLIENT_ID_WEB); -#elif !defined(SE_PLATFORM_IOS) +#else srand(time(NULL)); const char* charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; std::string code_verifier; @@ -691,6 +691,8 @@ void cloud_drive_authenticate(cloud_drive_t* drive) pJNIEnv->CallVoidMethod(nativeActivity, MethodOpenURL, jstrURL); pJavaVM->DetachCurrentThread(); } +#elif SE_PLATFORM_IOS + se_ios_open_url(request.c_str()); #else printf("Navigate to the following URL to authorize the application:\n%s\n", request.c_str()); #endif diff --git a/src/ios_support.h b/src/ios_support.h index a7a1d5b46..3f68f734c 100644 --- a/src/ios_support.h +++ b/src/ios_support.h @@ -4,4 +4,5 @@ void se_ios_open_file_picker( int num_extensions, const char ** extensions); void se_ios_get_safe_ui_padding(float *top, float* bottom,float* left, float *right); void se_ios_set_documents_working_directory(); +void se_ios_open_url(const char * url); #endif diff --git a/src/ios_support.m b/src/ios_support.m index f213584dc..5ab3ab0e7 100644 --- a/src/ios_support.m +++ b/src/ios_support.m @@ -116,3 +116,8 @@ void se_ios_get_safe_ui_padding(float *top, float* bottom,float* left, float *ri if(right)*right = window.safeAreaInsets.right; } } +void se_ios_open_url(const char * url){ + NSString* urlString = [NSString stringWithUTF8String:url]; + NSURL* nsurl = [NSURL URLWithString:urlString]; + [[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:nil]; +}