我正在构建一个iOS应用程序并尝试使用SoundCloud API。我注册了我的应用并创建了一个redirectURI:APP_NAME:// soundcloud。然后,在Xcode中,我添加了一个URL方案作为APP_NAME,URL标识符添加为com.BUNDLE_IDENTIFIER,并在我的AppDelegate中执行以下操作:
[SCSoundCloud setClientID:@"CLIENT_ID"
secret:@"SECRET"
redirectURL:[NSURL URLWithString:@"APP_NAME://soundcloud"]];
如果我在模拟器上启动应用程序,然后在Safari的地址栏中输入APP_NAME:// soundcloud,它会成功将我反弹回我的应用程序。但是,在应用程序中,我不断收到以下错误:
*** Assertion failure in +[SCRequest performMethod:onResource:usingParameters:withAccount:sendingProgressHandler:responseHandler:]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Resource '(null)' is invalid because the scheme is not 'https'.'
为什么资源'(null)'和方案'https'?我在哪里更改此更改以及如何解决此错误?
该方法调用SCRequest
performMethod
方法并需要https链接,这意味着不支持深入链接到其他应用程序。
NSAssert1([[aResource scheme] isEqualToString:@"https"], @"Resource '%@' is invalid because the scheme is not 'https'.", aResource);
要解决此问题,请在您的应用中实施Universal Links,如果设备上安装了https链接,则会将其重定向到您的应用。