react-native - 不支持的操作方法签名。必须返回 MPRemoteCommandHandlerStatus
问题描述
每当我在 iOS 13+ 上运行模拟器时都会出现此错误。一切都适用于 iOS 12 及更低版本,所以我不确定在这里做什么。有什么我可以更改/编辑的东西来react-native-music-control
为 iOS 13 工作吗?
Exception 'Unsupported action method signature. Must return MPRemoteCommandHandlerStatus or take a completion handler as the second argument.' was thrown while invoking enableControl on target MusicControlManager with params ( pause, 1, { } )
解决方案
这react-native-music-control
可能还没有更新它的 iOS MediaPlayer 方法。一种常见的方法是 MediaPlayer 的addTarget
. 从 iOS 13 开始,此方法必须返回一个MPRemoteCommandHandlerStatus
. 它过去在以前的 iOS 版本中不返回任何内容。
例如,如果您有一个play
在点击播放按钮时被调用的方法:
- (void) play {
/* start playing */
}
您可能正在注册它play
以在触发媒体播放器的play
命令时调用:
[[MPRemoteCommandCenter sharedCommandCenter].playCommand addTarget:self action:@selector(play)];
然后,您只需要简单地更改您的play
方法以返回MPRemoteCommandHandlerStatus
如下所示:
- (MPRemoteCommandHandlerStatus) play
{
// if successfully played
return MPRemoteCommandHandlerStatusSuccess;
// else if there's an issue
// return MPRemoteCommandHandlerStatusCommandFailed;
}
这是在Objective-C中。在 Swift 中更改返回值也很简单。
推荐阅读
- coq - Coq 只简化/展开一次。(用函数的一次迭代的结果替换部分目标。)
- php - 应用程序 Azure Api 中的 NoPermissionsInAccessToken 以创建联系人
- wordpress - Wordpress wp_login 挂钩未按预期工作
- c# - Facebook 身份验证被禁止
- qliksense - 在哪里为本地 Qlik Core 实例添加许可证信息
- excel - VSTO COM 加载项中的多个范围选择失败,但在 VBA 中完美运行,这里有什么问题?
- php - 为 PHP 7 在 xampp windows 8 上安装 Curl
- r - 可以连接到R中原始字符串的所有子字符串组合
- intellij-idea - IntelliJ IDEA 中的 PsiLambdaExpression
- javascript - 用 javascript 替换不同的 html-text 以翻译页面