Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 处理Dropbox身份验证响应_Ios_Dropbox Api - Fatal编程技术网

Ios 处理Dropbox身份验证响应

Ios 处理Dropbox身份验证响应,ios,dropbox-api,Ios,Dropbox Api,Dropbox文档解释了默认情况下,身份验证响应被激发到Appdelegate.m中 我如何让同一个火成为我自己班级的代表 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url sourceApplication:(NSString *)source annotation:(id)annotation { if ([[DBSession sharedSession] handleOpenURL:url]) {

Dropbox文档解释了默认情况下,身份验证响应被激发到Appdelegate.m中 我如何让同一个火成为我自己班级的代表

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
    sourceApplication:(NSString *)source annotation:(id)annotation {
    if ([[DBSession sharedSession] handleOpenURL:url]) {
        if ([[DBSession sharedSession] isLinked]) {
            NSLog(@"App linked successfully!");
            // At this point you can start making API calls
        }
        return YES;
    }
    // Add whatever other url handling code your app requires here
    return NO;
}
在info plist url type-->url方案中,只需添加db YourAppKey即可调用此方法

此方法将被自动调用。我希望您已经从dropbox开发者网站创建了应用程序,并获得了appKey和appSecret。在应用程序委托NSString*appKey=@“中使用此代码


//使用此选项后,打开的url将自动得到调用

这些方法只在AppDelegate.m中响应,不能在它之外使用。 要在ViewController或任何类中使用,应使用post通知

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
    sourceApplication:(NSString *)source annotation:(id)annotation {
    if ([[DBSession sharedSession] handleOpenURL:url]) {
        if ([[DBSession sharedSession] isLinked]) {
            NSLog(@"App linked successfully!");
            // Post Notify here
             [[NSNotificationCenter defaultCenter] postNotificationName:@"applicationDidLinkWithDropbox"   object:self];

        }
        return YES;
    }
    // Add whatever other url handling code your app requires here
    return NO;
}
然后在类中接收此通知,例如在ViewController中:

- (void)viewDidLoad
{
    [super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(dropBoxDidLink:)
                                                     name:@"applicationDidLinkWithDropbox"
                                                   object:nil];
}
- (void) dropBoxDidLink:(NSNotification *)notification {
    if ([[notification name] isEqualToString:@"applicationDidLinkWithDropbox"]) {
    //Handle your task here

    }
}

是 啊希望我在Dropbox中创建了应用程序,并获得了应用程序密钥、密钥,我在Appdelegate.m中使用了这些密钥,但我如何在自定义类上实现您的代码呢。你能帮我吗?我已经按照他们的文档进行了操作,但我的要求是我需要在自定义类中使用它们。就是这样。在info plist url type-->url方案中,只需添加db YourAppKey,此方法将获得调用,无需应用程序委托代码。我已经更新了文档,请检查一下。您好。朋友。一切正常。但我不想在APPDELEGATE.m中使用这些语句。你有我的要求。请?我认为你没有选择在哪里实现
openURL
。我相信它必须是
UIApplication
类的成员(通常位于名为
AppDelegate.m
的文件中)。
- (void)viewDidLoad
{
    [super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(dropBoxDidLink:)
                                                     name:@"applicationDidLinkWithDropbox"
                                                   object:nil];
}
- (void) dropBoxDidLink:(NSNotification *)notification {
    if ([[notification name] isEqualToString:@"applicationDidLinkWithDropbox"]) {
    //Handle your task here

    }
}