CocoaSoundCloudAPI を使用して、Cocoa で OSX 用の基本的なデスクトップ アプリを作成しようとしています。
認証に苦労しています。ログイン ボタンをクリックすると、アプリの認証を試みる外部ブラウザ ウィンドウが開きます。「接続」をクリックすると、接続ボタンに素敵なアニメーションが表示されます...永遠に、[SCSoundCloud account]
nullです。
ただし、このプロセス中に外部ブラウザ ウィンドウで [キャンセル] をクリックすると、SCAccount が!nil
誰でもこれを説明できますか?
これが私のコードです:
#import "SCMAppDelegate.h"
@implementation SCMAppDelegate
+ (void)initialize
{
[SCSoundCloud setClientID:@"MYID"
secret:@"MYSECRET"
redirectURL:[NSURL URLWithString:@"sampleproject1://oauth"]];
}
- (IBAction)login:(id)sender
{
[SCSoundCloud requestAccessWithPreparedAuthorizationURLHandler:^(NSURL *preparedURL){
// Load the URL in a web view or open it in an external browser
[[NSWorkspace sharedWorkspace] openURL:preparedURL];
}];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
{
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self
andSelector:@selector(handleURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
}
- (void)handleURLEvent:(NSAppleEventDescriptor*)event
withReplyEvent:(NSAppleEventDescriptor*)replyEvent;
{
NSString* url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
BOOL handled = [SCSoundCloud handleRedirectURL:[NSURL URLWithString:url]];
if (!handled) {
NSLog(@"The URL (%@) could not be handled by the SoundCloud API. Maybe you want to do something with it.", url);
}
NSLog(@"This is the account: %@", [SCSoundCloud account]);
}
@end
私はhttps://github.com/soundcloud/CocoaSoundCloudAPI/blob/master/GeneralUsage.mdをガイドとして使用してきましたが、ほとんどのものが機能することがわかりました。誰かが私を正しい方向に押し進めることができますか?