我正在尽最大努力开发基于Spotify的应用程序,该应用程序将为Premium Spotify会员和免费会员的部分音轨流式传输整个曲目。我正在我的appdelegate.m中初始化Auth进程并收到此消息“对于loginURLForClientID,'SPTAuth'没有可见的@interface”。这是我正在使用的Spotify示例代码。
#import <Spotify/Spotify.h>
#import "AppDelegate.h"
// Constants
static NSString * const kClientId = @"Your-Client-Id";
static NSString * const kCallbackURL = @"Your-Callback-URL";
static NSString * const kTokenSwapServiceURL = @"http://localhost:1234/swap";
@interface AppDelegate () <SPTAuthViewDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Create SPTAuth instance; create login URL and open it
SPTAuth *auth = [SPTAuth defaultInstance];
NSURL *loginURL = [auth loginURLForClientId:kClientId
declaredRedirectURL:[NSURL URLWithString:kCallbackURL]
scopes:@[SPTAuthUserReadPrivateScope]];
我在[auth loginURLForClientID]收到错误。我已经尝试将SPTAuth添加到我的@interface,但可能做错了吗?我不知道。请帮忙。另外....我用Swift尝试了这个并得到了类似的错误。
答案 0 :(得分:0)
尝试使用这些代码,这将适用于新的Spotify SDK:
SPTAuth *auth = [SPTAuth defaultInstance];
auth.clientID = @kSpotifyClientId;
auth.requestedScopes = @[SPTAuthUserReadPrivateScope,SPTAuthStreamingScope,SPTAuthPlaylistModifyPrivateScope,SPTAuthUserReadEmailScope,SPTAuthUserLibraryModifyScope,SPTAuthUserLibraryReadScope,SPTAuthPlaylistReadPrivateScope,SPTAuthUserReadPrivateScope];
auth.redirectURL = [NSURL URLWithString:@kCallbackURL];
#ifdef kTokenSwapServiceURL
auth.tokenSwapURL = [NSURL URLWithString:@kTokenSwapServiceURL];
#endif
#ifdef kTokenRefreshServiceURL
auth.tokenRefreshURL = [NSURL URLWithString:@kTokenRefreshServiceURL];
#endif
auth.sessionUserDefaultsKey = kSessionUserDefaultsKey;