Multiple iOS apps with single database and single log on - ios

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.

Related

iOS Switch between Parse Server Connections with a button click

Is it possible to initialize Parse configuration more than once in the app through a button?
The scenario is, Add a button inside a ViewController. When clicking, the app switches from my current live parse server to the testing server and vice versa.
Taking into consideration that the app cannot be killed and forced to restart as stated in apple documentation.
You have 2 options:
With Parse IOS SDK - Parse client is a singleton means that you can create only one instance of it. If you don't mind that users will need to close and open your app what you can do is to use NSUserDefaults there you can save the mode of the client (Test or Prod). Again... Users will need to manually restart the app.
Without Parse IOS SDK - it can be done (without restarting the app) only if you will create a custom REST client that will work against Parse REST API. In this way you can create as many client as you want and each client will have it's own configurations.

Using Firebase with multiple users in an iOS app

A number of iOS apps I develop are used in scenarios where the Organisation has a number of Drivers and the iPhone is shared between them. Each Driver has his own app credentials, logs in to the app, and is presented with his own set of data. The Firebase data is persisted as he is offline most of the day and I use keepSynced(true) to ensure data is up-to-date.
The problem I'm having is that once a user logs out with the Firebase method FIRAuth.auth()!.signOut() then when a different user logs in, he sees the previous users' data. I'm guessing that because the data is persisted it is not cleared from the cache. However, I am retrieving the data by the user id so this doesn't quite explain it.
What is the best pattern to permit multiple users to use the same iOS app with Firebase ?
Try creating multiple instances of FIRApp, each with a different name, using the +configureWithName:options: method. Then use the different apps in FIRAuth +authWithApp and elsewhere as needed.
I haven't actually done this and am too new to Firebase to say it's the best pattern, but it seems like it should work.
One thing to note from the docs is that, "On Android and iOS, Analytics are only logged for the default app." One solution might to keep the __FIRAPP_DEFAULT app, and then make a named app for each user type.

iOS - Get data from other app, communication between two

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

Store temporary data outside of iOS app

I have an app that is uniquely branded for each customer (think restaurants, etc.) I need to have the user be able to click on a link to my server that contains a unique code, stores that temporarily on the iOS device (cookie, etc.) and then directs them to the app store to download the app. Then when it is downloaded, the app grabs that cookie or temp. data on launch and brands the app for that customer. I know this is possible on Android, but is it on iOS?
Downloading the app first and then selecting the brand (or restaurant) is not feasible in this case, as the url wil be shared with other customers of the same business and we want to create a fluid experience, where they won't be able to "see behind the scenes" and choose a different branding.
Thanks
Edit
Thank you for all the replies. We've reevaluated and are considering having the url be opened on the device and grabbing the IP address or another unique id, and saving that along with the correct brand to a database. The app will then connect to the database on launch, and if the IP's match, will brand accordingly. We're looking for a more reliable identifier than IP, however. Now that UDID is deprecated, are there any other identifiers we can use?
I think the design you propose of a webserver link creating the code that needs to be read by the iOS app later is the issue. You should have a solution that is entirely app based. Perhaps you can have the same services on the website be available as one app which then sets up the code in pasteboard. The user then launches the actual app that looks at the pasteboard and skins itself accordingly.
That being said, data can be shared between apps from the same app seed ID by using UIPasteboard in addition to a few other ways.
I use the pasteboard to share info between apps quickly and easily using this class.
You can use identifierForVendor (UDID replacement) to identify individual devices. Are you planning on harvesting those identifiers prior to the end user "registering" the device at the final location? If not you'll never be able to determine which device belongs where.
What about having the end-user logging into your server as that restaurant? It can be a somewhat generic login per restaurant like "Wendys/Wendys5?" and "McDonalds/McDonalds7!" to determine their App Store URL. As long as the password is easy and non-programmatic to guess it would be unlikely they figure out how to register as a different restaurant. You could also do a simple restaurant selection screen coupled with a password specific to each chain but this would expose the user to which other restaurants are using the app. This way you won't have to continually add IPs if they expand locations and can revoke credentials if the login is compromised.
One question, though: Do all of your clients understand that they'll have to have an AppleID tied to each device? You can only shared a single AppleID across 20 devices.

share core data between many users on app

I wanna develop an iOS app as the platform for many users. Is it possible to enable multiple users of my app to share resources on the same core data database?
The other alternative to iCloud (with the whole ownership issue) is to have an online server that stores the data remotely.
Then you can create a web service to store and retrieve the data from the server onto the device.
yes This can be done using a custom url scheme on the iphone by help of iCloud URL.
but it has some dark sides.If you use a custom url scheme, only one application "owns" the data. The other application would have to import data from the main application.
another method is system pasteboard i.e. clipboard. you can put stuff on it and then launch another application with a URL that tells the other app to check the pasteboard.There's also the system pasteboard .
for more information on custom URL scheme check this link

Resources