iOS - Get data from other app, communication between two - ios

I have two apps, the first app calculate information automatically in background, the second app need to read this information periodically, how can I do to create interaction into two apps, can I use a file to do this ?

apps are sandboxed ... meaning one app cannot talk to another app directly either read its data or share.
The only thing you can do is send info from one of your app to a server and read that info from that server in your second app.

Your apps can interact via App Groups. First app create a file into shared container and other read it.

Yes Communication can be made between two applications in iPhone but limited to a handful of scenarios.
1>There might be apps which need to be sending to background according to some event like phonecall,etc.In Such cases you will have to configure your audio-session object (a Voip based app) and send notification accordingly.
2>The previous example is just interacting between apps with extremely less flexibility(sending app to background on some important built in event).The other way to do this is through URL Schemes , apple has some built in functionality and support for certain applications such as mail.tel , etc.But one of the application will come to foreground.
Like you can call a phone number , which is built in application using :-
NSString *phURL= [NSString stringWithFormat:#"tel:%#", [NSString StringWithString:#"1-800-555-1212"]];
NSURL *phoneURL = [NSURL URLWithString:phURL];
[[UIApplication sharedApplication] openURL:phURL]];
By the way it's along story if You need to implement a Custom URL Schemes..have fun with it.
3>The other way is through UIDocumentInteractionController which provides in-app support to have interaction between certain files.(Sandbox environment inhibits a complete access or even accesses that can modify data of other application).Like it can be used to preview files in mail app or download attachments.But you cannot modify them for other application , of course you can copy it and modify it for your application.
Source: Link

Related

Multiple iOS apps with single database and single log on

I created multiple apps in android with single database (Content provider) , single log on (which means if i login in one app it should work for all , if I logout from one app it should logout from all other apps) , I have to open one app from another app and every day I have to update all my off line data to server (it should happen particular time on every day ) . Now I am going to port this system (all apps) to iOS , is it possible in iPhone ? And I am not going to submit this apps to app store.
Yes it is possible. You would need to save your database at container url which you can get using:
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier;
The groupIdentifier param needs to be same for all the apps and needs to be configured inside Target->Capabilities->App Groups.
Once you have configured same appGroup for each application, you can use above method to save database at the location, provided by the method. That way the same DB would be accessible to all the apps.
There is NSUserDefaults init methid which takes suitename(appGroup), and creates a shared UserDefaults, which can be used for your single log-on purpose.
- (instancetype)initWithSuiteName:(NSString *)suitename;
Refer:
containerURLForSecurityApplication
NSUserDefaults
You can use AppGroups to share files between your apps. Using AppGroups you can implement a Single Sing-On functionality by storing a Bool in your database that each of your apps have access to that indicates whether the user is currently signed in or not and act accordingly when opening one of your apps.

How to read content of an iOS app from another app?

I am stuck somewhere. My client wants me to develop an application that has a dedicated icon over other applications as well. For example – If I have an ecommerce application opened in my iPhone, there should be an icon over that application through which I can take screenshot and add the image to my application. I know this is possible in android, but is it possible in iOS as well, if yes then how?? Also refer the image attached for more clarification.
Share data between two applications
Historically, the iPhone has tried to prevent data sharing between apps. The idea was that if you couldn't get at another app's data, you couldn't do anything bad to that app.
In recent releases of IOS, they've loosened that up a bit. For example, the iOS programming guide now has a section on passing data between apps by having one app claim a certain URL prefix, and then having other apps reference that URL. So, perhaps you set your event app to answer "event://" URLs the same way that a webserver answers for "http://" URLs.
Have a peek under "Implementing Custom URL Schemes".

Is it possible for an app to obtain the information about how long the user uses another app?

In iOS, is it possible for an app to get the information about how long the user uses another app?
In iOS each app runs in its own sandbox and cannot see data from other apps, even apps from the same publisher. An app can access special shared data, like photos from the album or contact data, but it is not possible for an app to directly access information like you have mentioned.
No, there isn't. There is no way to fetch data from another app, this is part of the App Sandboxing principle.

Way to track users between apps?

Let's say I have 3 apps, how can I track users between those apps? I want to see if a user in one app has downloaded a second app of mine and combine that data on the backend. I know I could ask for some sort of identifier (email, phone, etc.), but how can I do that without doing that? I don't think I am allowed to use the IDFA for this, but I'm not 100% sure.
The first thing you should do is check to see if any of your other apps are installed. You should give your apps a custom URL scheme (as posted by #mika) so they can be found. Then check to see if the app exists on the device by checking:
if ([[UIApplication sharedApplication] canOpenURL:yourCustomURLScheme])
To share the data between the apps, configure an app group for your apps.
From the Apple Docs:
Use app groups to allow multiple apps access to shared containers and
allow additional interprocess communication between apps. To enable
app groups, in the Capabilities pane, click the switch in the App
Groups section. You can select existing app groups from the table or
add app groups.
I believe that this would be a simple way of "tracking" them.
You could use Custom URL Scheme to find out what of your apps were installed by a user.
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
Then you can flag you tracking data accordingly.
Google Analytics can be configured to share tracking between apps. https://support.google.com/analytics/answer/2587087?hl=en

how to add one or more apps in single app

I have a situation,
where more than two separate iOS apps together to form a single app. The apps have entirely separate to each other and concept is money based program. Is there any way press a button and one project would run. And the press another and another project would run.
In App Purchase will help for this question, like this
Notification center label http://imagizer.imageshack.us/v2/800x600q90/12/v4v4.png
Second, How to update that single app when more than one app was incorported and how to show notification on top of the app. Is there is any tutorial for this question.
Please help me, I saw one or two solution but i didn't get any idea for this question.
It is easy. Just use an open url scheme and give the link to the other iOS application that you wish to open from within your application.
Refer to "Communicating with Other Apps" in the following developer documentation:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html
NSURL *myURL = [NSURL URLWithString:#"itunesLinkToOtherProject"];
[[UIApplication sharedApplication] openURL:myURL];
To come back to your app from the other application, use a similar custom URL scheme for your app within the other application. Thus you will be able to go from your app to the other app and vice versa.

Resources