Scenario for offline file access - ios

Scenario:
After downloading the file from Server, we have to store it in device’s local and fetch from their for later use.
This is for reducing unnecessary hits to DB to get the same file again and again. And accessing file offline too (when user don’t have internet access, he can able to fetch file from local).
How can we implement the above scenario in iOS devices for videos?

This solution will work only if files have unique names.
You can create a local db in which you have to store all file names which you have already downloaded from server.
Whenever user want to see a file you have to first check thes local db.
If file is already downloaded you can take the file and play it.

Related

Storing a text file in iCloud in Xamarin

I need some clarification and Microsoft documentation is only confusing me more.
I want to save a txt file in iCloud so the user doesn't loose some data that belongs to them.
This db document is some information I am retrieving from a local database and storing in a text file. I have seen two ways of doing this.. however all the posts on this topic are very outdated and I don't know which way might be best or if they are even doing what I trying to do.
All I would like is to be able to have the user backup this particular file to their iCloud account, so they can still keep this info even if they change phones or delete the app and want to restore from iCloud.
Microsoft's documentation points me to this page https://learn.microsoft.com/en-us/xamarin/ios/data-cloud/introduction-to-icloud
I began setting up the provisioning profiles and setting the iCloud options on the entitlements page etc. However the documentation when sideways for me when they began creating a monkey page UI Document and having the user manager the ubiquity documents (which I don't want) I actually don't want the user even seeing this Txt file. However this option shows how to check if the iCloud is even turned on on this user's phone.
Now this other option I think is more straight forward and I read the documentation on it here https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/file-system using something like this to store and retrieve a document:
var libraryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "..", "Library");
However what if iCloud is turned off? Is this an automatic backup option?
Any type of explanation is helpful.
The iCloud storage API in iOS 5 allows applications to save user documents and application-specific data to a central location and access those items from all the user's devices.
About the definition of iCloud, you will know that it will save your data to cloud server. And it can be used in all the user's device if turn on the iCloud.
However what if iCloud is turned off?Is this an automatic backup option?
Therefore, if iCloud is turned off, you could backup the data in device although it will not be used for other user's devices. You could save it in Application directories. This should be a good chooice to backup your data. And you also can get the data when you need them.
In addition, you also can use other cloud server APIs to backup your data. Such as Azure Storage, Firebase Storage etc.

How to allow the folder to be modified by the app only?

I've a strange requirement regarding for my app which using the Google Drive SDK. I'm creating a folder and a file(Single File) through app on the Google Drive. Now I want that folder to be modified by the app only. Is this feasible?
Why I need this?
I'm writing/syncing my app data to the user's drive. I'm creating a Folder and a file on the Drive.
Now the file can be modified by the user if he visit the Drive on browser or by some other medium.
So, If the file is modified, user will not be able to access his synced data on other devices.
I do not have my own server where I can store the data.
So, I want that file should be modified by the app only. How can I do this? Is this feasible with the current SDKs available? What else are the alternatives for me to get the project done?
Please Note : I do not have my own server.
I don't think this is feasible for the reason that I haven't read anything about it in the docs nor have I seen a working implementation of it.
The closest thing I can relate to this is Permissions for Shared Files's. But the restricting of file/folder happens to both browser and native app. They're always synced.
You can set the restricted folder to Reader role. Users will only be allowed to:
-Read the metadata (e.g. name, description) of the file or folder
-Read the content of the file
-Read the list of items in the folder
Check this iOS code on how to set the permissions.

How to save my data in iOS document folder?

My application need to save data to my local database. The reason why I want to save it to document folder is I want the data shared by all devices with the same iCloud account. What I normally do is to copy the empty database from my Bundle into my document folder the first time when the app launch. But I'm not very sure it will be rejected by Apple or not? (Because one of my app which preloading a database into document folder was rejected.) Do you have better strategy? (I know I can save the data into library folder. But the data will not be synchronized then.)
Thanks.

Best place for saving user data for Windows Store App

Disclaimer: I am new to Windows Store App development.
My app is a Windows Store App (for desktop). The app has to create some content using user's input and the data can be considered as documents. Also, the document'd be in a proprietary format. The user should be able to see all those documents listed inside the app every time he launches it.
My question is where to save these document files. I have no issue it is directly accessible to users without using app (it is their data).
The document suggest roaming (limited storage) and local storage. But both are deleted once the app is deleted (bad for the user).
http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
Document also states that accessing right for My Document folder is granted only if the developer is a company (bad for me).
http://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx
Any other popular pattern from developers (apart from Azure, SkyDrive and any online storage)?
On app's first launch, you can allow the user to choose his/her folder as per choice, and then add that folder in future access list. So you can access that folder anytime. Please check below given links.
How can I save a StorageFile to use later?
Exploring WinRT: Storage.AccessCache
Windows.Storage.AccessCache Classes

iCloud upload progress and keys

I'm trying to push a file to iCloud from one of my apps but sometimes there is no way to track if the file is already on iCloud or not. After marking the file as ubiquitous I have a method that periodically checks the status of the files via a NSMetadataQuery. When I get the results back I use these keys for the status of the file:
NSNumber *isUploaded = [file valueForAttribute:NSMetadataUbiquitousItemIsUploadedKey];
NSNumber *isUploading = [file valueForAttribute:NSMetadataUbiquitousItemIsUploadingKey];
NSNumber *uploadPercent = [file valueForAttribute:NSMetadataUbiquitousItemPercentUploadedKey];
This seems to work sometimes but in other times the isUploaded value is 0 and the isUploading value is also 0! The uploadPercent value is actually always 0. When I go into the 'Settings' app of my device and check the files for my app the files are already listed there so I'm not sure why the 'NSMetadataUbiquitousItemIsUploadedKey' key would return 0?
Any help is appreciated! Thanks!
I'm trying to do the same thing. Per the iCloud guide, try NSURLUbiquitousItemIsUploadedKey instead of NSMetadataUbiquitousItemIsUploadedKey. Let me know if that works for you. I still haven't been able to get this working. Here's the section from the guide:
Determining the Transfer Status of a File or DirectoryItems you write to an iCloud container directory are transferred automatically to the iCloud server as quickly as possible. However, depending on the network and the type of device, a file might not be uploaded to the server or downloaded to a device immediately. In cases where you need to know the state of a file, you can use the getResourceValue:forKey:error: method of NSURL to retrieve the value for one of the following attributes:NSURLIsUbiquitousItemKey—Indicates whether or not the item is stored in iCloud. NSURLUbiquitousItemIsDownloadedKey—Indicates whether the current version of the item is downloaded and accessible.NSURLUbiquitousItemIsDownloadingKey—Indicates whether the current version of the item is being downloaded and is not yet available.NSURLUbiquitousItemPercentDownloadedKey—For an item being downloaded, indicates what percentage of the changes have already been downloaded. You can use this value to update progress bars.NSURLUbiquitousItemIsUploadedKey—Indicates that locally made changes were successfully uploaded to the iCloud server.NSURLUbiquitousItemIsUploadingKey—Indicates that locally made changes are being uploaded to the iCloud server now.NSURLUbiquitousItemPercentUploadedKey—For an item being uploaded, indicates what percentage of the changes have already been uploaded to the server.Although the iCloud server aggressively pulls changes your app makes locally, iOS devices typically do not pull changes from the server until you try to access the file. If you try to open a file that is currently being downloaded, iOS blocks the thread that issued the open request until the file is downloaded and available for use. Thus, if you are concerned about potential delays, check the file’s current state as needed and possibly update your user interface to reflect that the file is not yet available or is currently downloading.For more information about the attributes you can request for URLs, see NSURL Class Reference.

Resources