使用适用于iOS的Dropbox Chooser SDK时无法生成链接错误

时间:2013-07-22 10:36:42

标签: iphone ios objective-c dropbox dropbox-api

在我的应用中,我已经集成了Dropbox Sync SDK。因此,当适用于iOS的Dropbox Chooser SDK进来时,我试一试。

我的问题是,当我在实际设备上测试时,它说

  

“无法生成链接。抱歉,发生了错误。请稍后再试。”

//注意:他们说“您可能有一个项目需要多个应用程序密钥,因为它也使用Core或Sync API。在这种情况下,您需要使用右侧显式初始化您自己的Chooser实例app-key使用-initWithAppKey:方法。“

更新 因为我已经为Sync API提供了相同的URL方案,所以我所做的是在我的 AppDelegate <中使用-initWithAppkey:方法初始化另一个Chooser实例 - application:openURL:sourceApplication:annotation: / p>

-(BOOL)  application:(UIApplication *)application
             openURL:(NSURL *)url
   sourceApplication:(NSString *)sourceApplication
          annotation:(id)annotation
{
  // instantiate a new DBChooser instance with Chooser Key
  // .. make sure it should not include 'db-' prefix
  DBChooser *chooser = [[DBChooser alloc] initWithAppKey:@"my-chooser-key"];
  if ([chooser handleOpenURL:url]) {
      // This was a Chooser response and handleOpenURL automatically ran the
      // completion block
      return YES;
  }

  return NO;
}

...和我最顶级的视图控制器。

- (void)didPressChoose
{
    // .. make sure it should not include 'db-' prefix
    DBChooser *chooser = [[DBChooser alloc] initWithAppKey:@"my-dropbox-key"];
    [chooser openChooserForLinkType:DBChooserLinkTypeDirect
                                fromViewController:self
                                        completion:^(NSArray *results)
    {
       if ([results count]) {

           // Process results from Chooser
           _result = results[0];
           NSLog(@"%@", _result.link);
       } else {

           // User canceled the action
       }
    }];
}

1 个答案:

答案 0 :(得分:2)

确保使用正确的app键执行请求。不是您用于syncer的那个,而是一个带有自己的app键的新Drop-in应用程序。

如果您这样做,请尝试管理您自己的DBChooser实例。现在,您获取一个实例并在其上调用init - 方法。您应该管理自己通过app分享的单例实例。您应该使用[[DBChooser alloc] initWithAppKey:@"my-dropbox-key"]创建该实例。永远不要在你的情况下使用defaultChooser。