'How do I programatically read the value of "Document Storage" setting from my app's Settings Bundle?
I am building an iOS application. The project started as an Expo Managed app, now I switched to the Expo Bare workflow (although I doubt this is related to the problem). My project has iCloud Document capabilities added. In general iCloud storage works fine.
On the default app's settings page (in the Settings app) I see "Document Storage" option, that provides two options: "iCloud Drive" or "Local Storage". I don't have any explicit Settings.bundle added to the project, so I guess it has to be either something auto-generated by the Expo build, or some default iOS settings based on app's capabilities. But my question is: How do I read the value of "Document Storage" programatically? I want to use that value as a user preference regarding where to store app's documents, either iCloud or locally.
I have already tried to list all the values of NSUserDefaults and examined them carefully for something that would look familiar but no success.
NSUserDefaults * standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSLog(@"%@", [standardUserDefaults dictionaryRepresentation]);
I also tried to obtain the value of the ubiquityIdentityToken under both possible settings of the option in question, but it returns the same, non-null value, no matter the setting.
- (NSString*) ubiquityIdentityToken{
__block NSString *token = nil;
runOnMainThread(^{
NSFileManager* fileManager = [NSFileManager defaultManager];
token = [fileManager.ubiquityIdentityToken description];
NSLog(@"ubiquityIdentityToken: '%@'", token);
});
return token;
}
void runOnMainThread(void (^block)(void)){
if ([NSThread isMainThread]){
block();
}
else{
dispatch_sync(dispatch_get_main_queue(), block);
}
}
Already been through countless Apple's and Expo's documentations but no success.
Edit: I tried on both emulator (iPhone 12 iOS 14.5) and a physical device (iPhone 11 with iOS 15.3.1).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

