繁体   English   中英

Dropbox iOS SDK始终为isLinked返回“是”:

[英]Dropbox iOS SDK always returns 'YES' for isLinked:

我正在使用iOS Dropbox SDK,并想检查我的App是否已与Dropbox帐户关联。 所以我做:

if (self.isLinked) {
    NSLog(@"linked");
}

但是self.isLinked始终返回YES 即使在清洁和重置iPhone Simulator之后。


仅在非真实设备上的iOS模拟器中运行时才会发生这种情况。 我不知道为什么会发生这种情况,但是如果Simulator上的Dropbox SDK的主机Mac与Dropbox帐户相关联,那么它也会被链接。

要在模拟器中获得逼真的行为,请在Dropbox首选项中取消Mac的链接。

2012年中的某个时候(找不到iOS SDK版本日志),Dropbox iOS SDK行为已更改为通过卸载/重新安装应用程序(甚至在设备上)来保持“链接”状态。 结果,在接收到“链接的”回调(例如我的回调)时执行某些操作的应用程序在重新安装后将无法工作。

一种解决方案是在首次运行时取消链接。 像这样:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    if ([[NSUserDefaults standardUserDefaults] objectForKey:HAS_RUN_KEY] == nil)
    {
        // ensure you have a DBSession to unlink
        if ([DBSession sharedSession] == nil)
        {
            DBSession* dbSession = [[[DBSession alloc] initWithAppKey:DROPBOX_KEY appSecret:DROPBOX_SECRET root:kDBRootAppFolder] autorelease];
            [DBSession setSharedSession:dbSession];
        }

        // unlink
        [[DBSession sharedSession] unlinkAll];

        // set 'has run' flag
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:HAS_RUN_KEY];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM