加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – Dropbox iOS SDK对isLinked始终返回“YES”:

发布时间:2020-12-16 03:25:41 所属栏目:百科 来源:网络整理
导读:我正在使用iOS Dropbox SDK,并检查我的应用程序是否已经与Dropbox帐户相关联.所以我做: if (self.isLinked) { NSLog(@"linked");} 但是,self.isLinked始终返回YES.即使清洁和重置iPhone模拟器. 这只会在iOS模拟器上运行时不在真实设备上.我不知道为什么会发
我正在使用iOS Dropbox SDK,并检查我的应用程序是否已经与Dropbox帐户相关联.所以我做:
if (self.isLinked) {
    NSLog(@"linked");
}

但是,self.isLinked始终返回YES.即使清洁和重置iPhone模拟器.

这只会在iOS模拟器上运行时不在真实设备上.我不知道为什么会发生这种情况,但是如果主机Mac与Dropbox帐户相关联,则模拟器上的Dropbox SDK也会相关联.

要在Simulator中获取现实的行为,请在“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];
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读