iOS Switch between Parse Server Connections with a button click - ios

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.

Related

What's the best way to create a custom sharing method on iOS?

A streaming app that I'm using on iOS has a share button that allows me to hook into the sharing app extension. I'd like to be able to send the URL string that it has to a custom API on my server.
Would I need to create an entire app just to have that custom sharing method, or is there another way?
If that's the only way, how can I get that app on my phone without going through the store?
It seems like when I create, build and install apps through Xcode, Apple intentionally breaks the app after a short while?

Will my app update automatically or will user need to update the app when the code is updated?

I am creating a weather app and want to give local warnings to people through an app. I want to be able to give up to date warnings, but I am wondering: does updating information in Xcode get automatically pushed to the devices or will it need an update every time I put new information in?
If I understand your question correctly - you have an app, which warns people about some unexpected weather conditions?
You basically have two options:
Do a code push to your app every time you do a change. This is not supported by default in Swift and Xcode, and can only be done via some third-party integration or framework (e.g. React Native), and is generally a hard thing to implement.
Setup a back-end server and link it with your app, so the new information is downloaded from this back-end server dynamically.
The only suitable and easy thing to do for your use case seems to be option 2.

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.

Initiate Parent iOS App Service Call from Today Widget Extension

I am working on a POC iOS application that will eventually be released through an internal enterprise MDM solution. The app itself is pretty straightforward. It makes a quick call to an internal endpoint to return some simple json and then displays it on screen. At the same time, I have an app extension (Today Widget) displaying a small fraction of that data as well.
I have created a shared framework that includes the service calls, as well as any other common code I am using. Unfortunately, the parent app and extension all work perfectly fine if I'm on the internal network where the service endpoints live. However, this app will not always be on our trusted, internal network. As a result, we wrap the build with a secure container provided by our MDM solution and open up traffic to our specific internal endpoints. This works perfectly fine for the app, but our MDM provider doesn't currently provide similar capabilities for App Extensions.
As a result, I am working to come up with creative ways to best ensure the data in my Today Widget is up to date without it directly making a service call. To do so, I am sharing data between the app and extension via an app group, but if the service call is only made from the parent app and the user very rarely accesses the parent app, the data will still be out of date.
In order to simulate making the service call from the app extension to update the data, I would like a way to call the service on behalf of the parent app, which would then update the NSUserDefaults data being shared between app and extension.
So my question: What is the best way for me to initiate that service call in the parent app? Is it even possible? I know Apple provides the 'openURL' method to allow an extension to open it's parent app, but I don't want to actually open the app. I want the app to be running in the background while the extension makes the service call on it's behalf.
I have been looking into the following, but with not much luck:
Parent app has an observer on NSUserDefaults, watching a specific key, that when modified by the app extension will fire off the service call to update the shared data being displayed. Unfortunately, I don't believe this will work, since as long as the parent app is in the background, the NSUserDefaultsDidChangeNotification will not get fired off in the parent app.
Send a local notification from app extension to parent app, telling it to fire off the service call and update data shared via app group. Unfortunately, UIApplication.sharedApplication() is not accessible from an app extension.
Any suggestions of ways to simulate the service call, to give my Today Widget the highest likelihood of being up-to-date with it's information?
Note: Obviously giving Today Widgets access to internal resources has it's own security concerns, but for this POC, the data is non-sensitive and must only live internally..

Create equivalent of Androids sync adapter on iOS

I got data on a webserver which I want to download to an iOS contact list. Is it possible to programatically create an account on iOS that works like the android "sync adapter" and is not one of the default account or an LDAP/CardDAV account?
Or can I have my application to periodically chech for updates on my webserver without the user having to manually start it. (i.e. running in the background and starting up automatically when the phone is restarted)
No, to both. The best you can do is create a configuration profile that the user can download to add an LDAP/CardDAV account—but you will need to run an actual LDAP or CardDAV server to have any kind of automatic contact syncing happen without the user opening your app. The Address Book framework on iOS only allows you to add and modify contacts within the existing accounts on the device, and the multitasking rules only allow your app to start in the background if it provides a VoIP service.
Use silverstripe-sync !
Source: SO

Resources