cod*_*nd1 9 objective-c dropbox ios
我正在使用iOS Dropbox SDK并想检查我的应用是否已经与Dropbox帐户相关联.所以我这样做:
if (self.isLinked) {
NSLog(@"linked");
}
Run Code Online (Sandbox Code Playgroud)
然而self.isLinked总是回来YES.即使在清洁和重置iPhone模拟器之后.
仅当在iOS模拟器中运行而不是在真实设备上运行时才会发生这种情况.我不知道为什么会这样,但如果主机Mac与Dropbox帐户链接,模拟器上的Dropbox SDK也会被链接.
要在模拟器中获得逼真的行为,请在Dropbox首选项中取消链接Mac.
Jay*_*ais 15
在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];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2437 次 |
| 最近记录: |