Dropbox iOS SDK始终为isLinked返回'YES': [英] Dropbox iOS SDK always returns 'YES' for isLinked:

查看:225
本文介绍了Dropbox iOS SDK始终为isLinked返回'YES':的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS Dropbox SDK并想检查我的应用是否已经与Dropbox帐户相关联。所以我这样做:

I'm using the iOS Dropbox SDK and want to check if my App is already linked with a Dropbox account. So I do:

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

然而 self.isLinked 始终返回 YES 。即使在清洁和重置iPhone模拟器之后。

However self.isLinked always returns YES. Even after cleaning and resetting the iPhone Simulator.

这仅在iOS模拟器中运行而不是在真实设备上运行时才会发生。我不知道为什么会这样,但如果主机Mac与Dropbox帐户链接,模拟器上的Dropbox SDK也会被链接。

This only occurs when running in the iOS simulator not on a real device. I don't know why this happens, but the Dropbox SDK on the Simulator also is linked if its host Mac is linked with a Dropbox account.

要获得真实的行为模拟器在Dropbox首选项中取消连接Mac。

To get realistic behavior in the Simulator unlink your Mac in the Dropbox Preferences.

推荐答案

2012年中期的某个时间(找不到iOS SDK版本日志)Dropbox iOS SDK行为已更改为保留通过卸载/重新安装应用程序链接'状态(甚至在设备上)。因此,在重新安装后,对接收链接回调(如我的)执行某些操作的应用程序将无法运行。

Sometime in mid-2012 (can't find the iOS SDK version log) the Dropbox iOS SDK behaviour changed to retain 'link' status through uninstall/reinstall of an app (even on device). As a result, apps that perform some action on receiving the 'linked' callback (like mine) would not work after a reinstall.

一种解决方案是在首次运行时取消链接。类似的东西:

One solution is to unlink on first-run. Something like so:

- (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];
    }
}

这篇关于Dropbox iOS SDK始终为isLinked返回'YES':的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆