iOS BoxSDK为sharedLink返回nil

前端之家收集整理的这篇文章主要介绍了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];
}
原文链接:https://www.f2er.com/iOS/333228.html

猜你在找的iOS相关文章