iOS BoxSDK为sharedLink返回nil

我们需要为文件创建共享链接,然后检索该链接
我们可以在我们的应用程序中显示它.
我们能够为特定文件创建共享链接(我们可以看到它
在Web上的Box帐户中)但我们无法检索sharedLink
通过API.尽管isShared方法返回YES,但它总是为零.

从BoxObject.h的头文件中我们发现这两种方法提供了
有关项目共享状态的必需信息.

@protocol BoxObject
// ...


// Information about the shared state of the item
@property (readonly,getter = isShared) BOOL shared;
@property (readonly) NSString *sharedLink;

//...
@end

这就是我们创建共享链接的方式.

>找到我们想要分享的BoxFile,让我们调用该对象照片
先前的调用方法shareWithPassword:message:emails:callbacks:,[photo
isShared]返回NO.
>我们称[photo shareWithPassword:@“”message:@“”电子邮件:[NSArray
arrayWithObject:@“”]回调:^(id< BoxOperationCallbacks>
ON1){…}];
>在on1.100之后我们检查是否响应== BoxCallbackResponseSuccessful
然后我们调用[photo updateWithCallbacks:^(id
ON2){..}]
>在on2.after我们检查是否响应== BoxCallbackResponseSuccessful
>成功回复[photo isShared]返回YES但是[照片
sharedLink]返回nil

如果我们检查网络,我们可以看到该文件实际上是共享的,但我们
无法从Box SDK中检索sharedLink.

有人有同样的问题吗?

解决方法

根据已发布的代码和github here上的信息,这对我有用
- (void) getShareableLinkForFileId:(NSString *)fileId 
{
    BoxFileBlock fileSuccess = ^(BoxFile *file) {
            NSDictionary *fileInfo = file.rawResponseJSON;
            if (![fileInfo[@"shared_link"] isEqual:[NSNull null]]) { 
            NSDictionary *linkData = fileInfo[@"shared_link"];
            //Do something with the link
        } else {
            // failure
        }
    };
    BoxAPIJSONFailureBlock failure = ^(NSURLRequest *request,NSHTTPURLResponse *response,NSError *error,NSDictionary *JSONDictionary) {
         //Handle the failure 
    };

    BoxFilesRequestBuilder *builder = [[BoxFilesRequestBuilder alloc] init];
    BoxSharedObjectBuilder *sharedBuilder = [[BoxSharedObjectBuilder alloc] init];
    sharedBuilder.access = BoxAPISharedObjectAccessOpen;
    builder.sharedLink = sharedBuilder;
    [[BoxSDK sharedSDK].filesManager editFileWithID:fileId requestBuilder:builder success:fileSuccess failure:failure];
}

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...