NSUserDefaults: Is it possible to get userDefaults from another app? - ios

There are two apps installed on iPhone (myApp and competitorApp).competitorApp is saving user settings with using NSUserDefaults. I know all keys (value forKey) which using competitorApp. Is it possible to get values in myApp from competitorApp?

In the iOS App Programming Guide, in the Security section you can read:
For security reasons, iOS places each app (including its preferences
and data) in a sandbox at install time. A sandbox is a set of
fine-grained controls that limit the app’s access to files,
preferences, network resources, hardware, and so on. As part of the
sandboxing process, the system installs each app in its own sandbox
directory, which acts as the home for the app and its data.
That means that if you're not interested in jailbreaking, what you want to do is not possible.

No. Apps cannot access each other's user defaults, nor look inside each other's file system sandboxes. This is security working as designed.

Jailbreak.. Better solution to save userdefaults values on some server and then download it in another app. Not possible otherwise

Related

iOS, config files and sandboxing

My understanding is that because of sandboxing, it isn't possible to view any text file (ie config file) associated with an iOS app using another app. Something quite simple with Android. Am I mistaken?
I am trying to implement a text config file with a Unity iOS app that gets loaded and parsed once when the application boots.
This config file would also be able to be edited and saved manually on that actual iOS device.
(addendum)
In Unity there is PersistentDataPath which resolves to /var/mobile/Container/Data/Application/foo/Documents
Is there an iOS supported file explorer app that will allow me view and edit files in this location (without jailbreaking)?
Use can check iOS App Groups. It allows multiple apps access to shared containers and allow interprocess communication. There is no so much documentation about this, but maybe that's what you're looking for. At least you can share NSUserDefaults between the apps.
NSUserDefaults it's a most simple way to save any (not big) configurations for your app. For manual editing: if your app on the device signed with developer certificate, you can connect through any iOS supported file explorer app and edit it. But after release, from App Store, your app installed in restricted/private path, so it's not possible, if only you don't have a jailbreak.
Initial configuration you can put into your app bundle, and at the first run just copy them to NSUserDefaults.
Short answer: There are utilities such as iExplorer - https://macroplant.com - that allow "file manager" type access. However...
Long answer: If your app requires users to buy (or get) other software to modify configuration files, the chances of Apple approving it are slim to none.
The appropriate thing to do is to provide a User Interface in your own app which allows the user to modify / update the settings.

App Groups and iCloud in iOS

I am familiar with iCloud syncing, but I am new to app groups. There may be a simple answer to this question, but I haven't found it yet. Basically, I have an app in which I have iCloud integration, and now I want to try to add a today extension. I am currently using Core Data as a backend and would like to continue to do so. However, from what I have read, I need to move my data store to a shared location by defining an "App Group". (http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios-8 and Accessing Core Data SQL Database in iOS 8 Extension (Sharing Data Between App and Widget Extension)) I haven't been able to find out if this location is synced using iCloud or not. Or, because I"m using iCloud, do I need an App Group at all? I appreciate any and all help/suggestions.
If you're already using iCloud, you don't need to use app groups, because your extension can access the same iCloud container as your app does. As long as your entitlements and provisioning are configured correctly, you can literally just use the same Core Data stack setup in the extension as in the app.
Apple's Lister demo project does this, but there's nothing special about it. Just use iCloud as usual.
App groups are usually necessary to share data between apps and extensions. But a big exception is when the data is already stored external to the app-- as with iCloud.

What is the expected lifecycle of iOS 8 App Group directories?

I am starting to investigate iOS 8 extensions, and I see that App Groups are the mechanism provided to pass data between the host app and the extension. This data sharing can be done with NSUserDefaults, flat files, and core data. When you setup an app group, a new directory is created on the device/simulator that is outside the application sandbox. That directory can be accessed from the host app and the extension, and it would appear that other apps from the same account/team can also access this directory.
Given all of this, I would like to know what the lifecycle of the shared App Group directory and its contents are. I have been unable to find any Apple documentation explaining this. Some empirical testing on the simulator has shown that when more than one application is installed that is accessing the app group, the directory is removed when the last application that has that App Group entitlement is removed. This is what I expected to see. I'd like some confirmation that this is the case. Also, is there any potential for the system purging this location under low disc conditions?
I'm trying to determine if it is "safe" to store my app's primary core data database in this App Group location, or if I should be making copies of data there instead. I don't want my main database to get wiped out from underneath me unexpectedly by the system.
Also, what is the intent for App Group directories? Should they be used for sharing data with extensions only, or are they intended as a general data sharing mechanism between apps from the same developer account/team?
I also posted this on the Apple Dev forums, and got an answer back from someone in Apple developer relations. Here is what they said:
Is there any potential for the system purging this location under low disc conditions?
That won't happen.
I'm trying to determine if it is "safe" to store my app's primary core data database in this App Group location, or if I should be making copies of data there instead.
Placing your core data store in an App Group directory is perfectly reasonable.
Also, what is the intent for App Group directories?
They are there so that suites of apps can shared data. I think the clearest expression of this comes from the Mac documentation. The "App Sandbox Design Guide" says:
[...] an application can use the com.apple.security.application-groups entitlement to request access to a shared container that is common to multiple applications produced by the same development team. This container is intended for content that is not user-facing, such as shared caches or databases.
Documentation

Get version number of other ios application

Is there any way to check version number of other application which is installed from appstore ?
Note:
1. Not in jail broken devices
2. With out using third party library.
Not Possible. your control is upto the level of your App Sandbox.
What is Sandbox?
For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.
It is not possible to check version of another application as in IOS, Applications work in SandBox environment which doesn't allow the application to access other application.
Two applications can communicate with the help of URL schemes,following is the link for URL Schemes of few Applications:
http://wiki.akosma.com/IPhone_URL_Schemes
http://handleopenurl.com/
using URL schemes we can access limited information(Exposed by the Developers of that application)
Although , there are few options,
1)If two application are using same/common web-services ,then this information can be shared
2)using ICloud this can be achieved If two application are using common/public space.

Is there a way to not erase the documents directory when uninstalling the app?

I'm developing an AIR app for iPad, and I found that when I uninstall the app, the documents directory data gets erased, is there a way to keep this data even when I delete the app or this behavior is regulated by iOS and there is nothing I can do about it?.
Thanks.
No you cant
From The iOS Environment
For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.
So you delete the application all the content regarding that particular app gets deleted.
as soon app get uninstalled the document directory folder also get deleted with that. Although you will not able to access that folder from other apps so there is no need to keep that.

Resources