How do I update my iOS app's content with background downloading? - ios

TL;DR: I want to add images to the app over the internet through background downloading of some sort, but don't know where to start, or what the best method is.
My app displays images to the users which can be filtered etc. I have a "Cards" class that has fields for name, image, etc. I then have a huge area directly in my code where I create instances of the Cards class for each image. There is then an array of these class instances, which helps with displaying them.
My issue is that now I want to be able to update this block of class instances without having to push another build to the iTunes store. Essentially, I want to add "Cards" to the app (images with appropriate names and keywords associated with them). I need to be able to update the app every month (sometimes less) with new cards as quickly as possible.
I have heard suggestions here and there about JSON files and background downloading, but can't figure out which method I need for my situation.

As per my understanding you just want to update your app content in future without uploading a new build to App Store. Right ?
If you want to do so, make your app so flexible that you can show updated contents in your app.
Here is a short instruction which you can follow...
Develop an admin panel if you are aware of any backend scripting language like php. And you can add contents from this panel into your database.
Create an API which will fetch the content from your database
Make your app flexible so that it can show all the updated content getting from the API. If you have a list of content then you can use TableView/CollectionView with pagination.
If you still face any problem then let me know. I will see deep into your problem.

Related

Priority of documents in elasticsearch

I have rails app witch collect mobile data and use elastic search as search engine in my app, As result that my app is very simple I use elastic as my db, every things goes fine till I found something amazing
In my case each user have two kind of document with different attributes, First one is profile that it's about user profile only and Second one is events that is user actions in mobile app. I have to say، user could update his/her profile and each user just have to one document in my system, that is about profile details. each time user update his profile I delete previous document and create new document for him but assume he send profile twice at same time unconsciously for example push register bottom twice at this point i get two document that are completely same so elastic save both but as i say i need to delete old one and create new one, I know I could handle this problem in mobile layer but I'm looking for some way witch make me sure at this situation document have their priorities.
Basically you need a versioning of your documents and using that you can control whether you need to create a new document or update existing document. this official Elasticsearch version control blog should help you design and implement this use-case.
I really hope I got your point correctly, consider the following points
prevent users from submitting twice in your front end.
update the document instead of deleting the previous one then creates a new document so that you don't have to worry about document priorities because of a single file.

Questions about ios14 widgets -- fetching dynamic data from container app

I am mainly just looking for clarification or resources. Let me explain my situation.
I have an app that internally relies on an always-up-to-date database of items. I'd like to show off items that were released close to today's date. I originally thought I'd just query my database and fetch the relevant items from there. So I began the long process of updating target values so the widget could see my classes, etc... But that was such a HEADACHE.
I thought surely there must be a more lightweight method the designers had in mind, so I then read about "app groups" and being able to pass information via saved settings/preferences. So basically when the app runs, you store some data as json and then you can fetch that information in your widget.
But then, to my knowledge, the data won't update unless the user runs the app again. I was hoping I could keep this widget up to date even if the user hasn't used the app in a long time.
What exactly is the process I should be using to achieve this? Are "app groups" basically the only way to do this? Will I just have to accept that I will often times have stale data?

PHAsset Create with Adjustment Data in One Go

TL, DR:
I want to create a new asset in the photo library and apply adjustment data (edits) to it, without the user being prompted twice.
The Background
I am developing an iOS photo editing extension, and providing similar functionality in the container app.
For better code reuse and modularity, I am adopting a PHContentEditingController-based flow on both the extension (required) and the container app, bundling all the shared components in an embedded framework that both the app and the extension link against (as recommended by Apple).
Unlike the app extension, which is "passed" an image to edit by the Photos app and executes under its supervision, the container app needs to request changes to the asset library, each resulting in the user being prompted for authorization.
On launch, the app offers the user two options for sourcing the image to edit:
Opening an existing photo from the library, or
Taking a new photo using the camera.
(both options rely on UIImagePickerController, of course)
Right now, the images read from the library undergo the same editing flow as they would within the app extension, with the only difference that my own UI code manually calls finishContentEditing(completionHandler:) on the (shared) object that adopts the PHContentEditingController protocol, and, on completion, it further calls the PHAssetLibrary method performChanges(_:completionHandler) (which triggers the authorization prompt).
This means that edits made within the container app can be reverted when re-editing the same image with the extension in the Photos app (and potentially vice-versa, too, once I get around supporting adjustment data).
For new images taken with the camera, however, I am taking a different approach. After applying the filters, I just save the result to the photo library using the legacy function:
UIImageWriteToSavedPhotosAlbum(_:_:_:_:)
(back from the time when argument labels weren't a thing yet :-)
The Problem
The problem with this approach is that edits are always 'baked in' for images taken with the camera and edited within the app (the can't be reverted). This feels arbitrary and perhaps even confusing to the user, so I'm looking for a more unified approach.
I could save the photo to the library right after the user takes it, and from there use the same flow as with existing assets, but this means that I need to modiufy the library twice:
Create a new asset
Save edits to the new asset
...which will result in the user being asked for permission twice: Once before editing the image, and once again on committing the edits.
So, my question is:
Is There a Way to Create a Library Asset "In One Go", Original Image and Adjustment Data?
Although I haven't tried this on my code yet (I have more urgent issues now), I seem to have found what seems to be the exact answer to my question in Apple's documentation for one of the initializers of the PHContentEditingOutput class:
init(placeholderForCreatedAsset: PHObjectPlaceholder)
From the docs:
Discussion
Use this method if you want to add a new asset to the Photos library
with edited content, as opposed to editing the content of an asset
after adding it to the library. For example, you might use this option
if your app applies filters to photos it captures with the device
camera—instead of saving only the filtered image to the Photos
library, your app can save both the filtered and the original image,
allowing the user to revert to the original image or apply different
filters later.
Also:
Note
If your app edits the contents of assets already in the Photos
library—including assets your app has itself recently added—Photos
prompts the user for permission to change the asset’s content. If
instead your app uses the init(placeholderForCreatedAsset:) method to
create an asset with edited content, Photos recognizes your app’s
ownership of the content and therefore does not need to prompt the
user for permission to edit it.
I guess we all need a healthy dose of RTFM once in a while! :-)

Can my iOS App load a XML file and Generate Interface from the information within XML?

I'm working on a home automation project. Here's what I want to do:
The app starts and it'll have a button to load an XML file.
The XML will have information about the rooms in the house like "Living Room, Dining Room, Kitchen etc.". It'll also have information about the equipment, like "Home Theater, TV, Blu-Ray Player, etc. in this case with a relation with the room that they belong" and so on with IR, RS-232 cmds, etc.
I'll install this app in different houses, so I intend just to change the XML file as the house changes.
I intend to generate the UI from the information contained in the XML file. E.g. The house has only "Living Room and Dining Room". The tab bar will show only those two tabs.
So, my questions:
Will Apple reject my app?
Can my customers just download the app from the App Store, and change and load the XML file? I mean, there's a package in the .app file, is it possible to open it and change the .xml file inside it?
Is it possible to change the UI as the XML information changes?
EDIT: more questions:
#competent_tech is saying that dynamic generation of code isn't allowed, but I'll change the code within the .storyboard or .xib .nib files, isn't it?
About the Contacts: I think is a little bit different idea, because in the contacts app, e.g.: there are 10 fields to fill out, like first name, last name, e-mail, phone number, etc. As a user, if I don't fill out the e-mail field, it'll still be there anyway. My plan is kind of different:
The house has 2 equipments to control: - Tab bar with item 1 and item 2.
The house has 3 equipments to control: - Tab bar with item 1 and item 2 and item 3.
Do you still think this is possible?
Can you recommend a book about this? I couldn't find anything useful myself.
Unfortunately, only apple can answer the rejection question.
However, from what you have described, there shouldn't be an issue since this is configuration-based changes instead of code changes. Apple specifically prohibits download of code and dynamic generation of code.
You can liken it to Contacts: iOS doesn't come configured with contacts, they allow you add them and configure different things about them. This sounds very much like what you are doing.
You should be able to download an XML file from a website or web service and use that to configure the app. We use a web service to retrieve data into the local Sqlite database to configure nomenclature and UI component visibility based on the current user and it works quite nicely.
With generating code they mean executable code, not the generating of views or viewcontrollers. If that is forbidden too, you could distribute your app via addhoc, but you need one developer program per 99 clients.

iOS Creating a User Manual for an App

I need to add a User Manual for my App, although all the user manual examples I have seen are web-based, which is convienent because it allows you to update the documentation without updating the app but also inconvient if the user is in a off-line mode.
What I envision in a helpful usermanual would be a popovercontroller that would display relevant data to whatever the current view has. It would retrieve documentation from the web and save it for later reference. Maybe even something that could take a document and break it into a plist by tag. Including gaphics would be nice also.
Are there any frameworks do to this available? ..... Or am I going to have to write my own.
How have other people implemented user manuals?

Resources