【问题标题】:no visible @interface for 'SPTAuth''SPTAuth' 没有可见的@interface
【发布时间】:2015-05-01 18:54:40
【问题描述】:

我正在尽最大努力开发一个基于 Spotify 的应用程序,该应用程序将为高级 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 尝试过这个并得到了类似的错误。

【问题讨论】:

  • 因为 Spotify 已经删除了这个方法。

标签: ios objective-c interface spotify


【解决方案1】:

试试这些代码,这将在新的 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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 2015-05-17
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 2016-08-05
    相关资源
    最近更新 更多