当前位置: 首页 > article >正文

解决cocos 2dx/creator2.4在ios18下openURL无法调用的问题

由于ios18废弃了旧的openURL接口,我们需要修改CCApplication-ios.mm文件的Application::openURL方法:

//修复openURL在ios18下无法调用的问题
bool Application::openURL(const std::string &url)
{// NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];// NSURL* nsUrl = [NSURL URLWithString:msg];// return [[UIApplication sharedApplication] openURL:nsUrl];@autoreleasepool {NSURL *nsUrl = [NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]];// 检查是否为 HTTP/HTTPS URLif ([[nsUrl scheme] isEqualToString:@"http"] || [[nsUrl scheme] isEqualToString:@"https"]) {if (@available(iOS 14.5, *)) {NSDictionary *options = @{UIApplicationOpenExternalURLOptionsEventAttributionKey : @YES};[[UIApplication sharedApplication] openURL:nsUrl options:options completionHandler:^(BOOL success) {if (success) {// URL成功打开} else {// URL打开失败}}];return YES;}}// 其他情况使用旧方法if (@available(iOS 10.0, *)) {[[UIApplication sharedApplication] openURL:nsUrl options:@{} completionHandler:nil];} else {[[UIApplication sharedApplication] openURL:nsUrl];}return YES;}return NO;
}

http://www.lryc.cn/news/2402594.html

相关文章:

  • 精益数据分析(94/126):30/10/10用户参与法则与定价策略的科学制定
  • oss:上传图片到阿里云403 Forbidden
  • Windows系统中如何使用符号链接将.vscode等配置文件夹迁移到D盘(附 CMD PowerShell 双版本命令)
  • 4. 数据类型
  • MySQL基础(二)SQL语言、客户端工具
  • 【贪心、DP、线段树优化】Leetcode 376. 摆动序列
  • CppCon 2015 学习:C++ in the audio industry
  • C++算法-动态规划2
  • 软信天成:数据驱动型背后的人工智能,基于机器学习的数据管理
  • MySQL提升
  • hbase资源和数据权限控制
  • VMWare下设置共享文件,/mnt/hgfs下却不显示共享文件的解决方法
  • go语言的锁
  • C++11完美转发
  • VUE解决页面请求接口大规模并发的问题(请求队列)
  • IDEA安装迁移IDEA配置数据位置
  • Blazor-表单提交的艺术:如何优雅地实现 (下)
  • 五子棋网络对战游戏的设计与实现设计与实现【源码+文档】
  • Vue基础(14)_列表过滤、列表排序
  • Spring Boot项目中JSON解析库的深度解析与应用实践
  • 我用Amazon Q写了一个Docker客户端,并上架了懒猫微服商店
  • Django CMS 的 Demo
  • 在 UE5 蓝图中配置Actor类型的Asset以作为位置和旋转设置目标
  • Android 之 kotlin 语言学习笔记四(Android KTX)
  • 适用于vue3的大屏数据展示组件库DataV(踩坑版)
  • mysql实现分页查询
  • Flink checkpoint
  • 【java】在springboot中实现证书双向验证
  • CppCon 2015 学习:Functional Design Explained
  • 基于3D对象体积与直径特征的筛选