Save mp4 file to local storage iOS - ios

I'm developing a mobile app in both android and iOS, I didn't had issue on android while using $cordovaFileTransfer. When I transfer to iOS I encountered a problem where accessing a persistent storage (by using cordova.file.*) sometimes makes the location available and sometimes null. Before I asked a question why does the location becomes null sometime. And now I saw that it shows the error "You don't have permission to access the filesystem". Is there a way for me to give permission to app while it's running? I tried cordova-diagnostic-plugin but it will only check if the app is permitted but no control on the permission.

Related

How do I properly enable iCloud document sync for iOS app?

In my cordova iOS app, users can back up their data to a file which is saved in the Documents folder within the app's container, which then should be synced to iCloud. However, though the file is saved it is never synced to iCloud, so clearly I must be missing something. These are the steps I have taken:
iCloud container registered on developer.apple.com and iCloud Documents capability enabled in xcode:
NSUbiquitousContainers dictionary added to Info.plist:
Archive build created and uploaded to App Store, build released to testers via Test Flight (Note: app has already gone through review process and been released to App Store).
Note, Cordova config.xml does not contain BackupWebStorage setting so cloud backup should be enabled (not sure exactly whether this affects document sync).
User saves backup file, which is saved to app's Documents folder (Note: the app uses the cordova-plugin-file plugin to save the file to the location denoted by the plugin variable cordova.file.documentsDirectory):
At this point I would have expected to see xBrowserSync appear in Storage & iCloud usage settings, but I do not:
And neither do I see an xBrowserSync folder appear in the iCloud Drive app:
And of course I never see the files synced to my Mac or on icloud.com.
Clearly I'm missing something but I can't see what. I've read many SO posts regarding getting this working and I find Apple's documentation unclear and confusing so I'm kind of stuck at this point. Could someone please point me in the right direction?
After some further reading I believe I know what's missing here. I hadn't realised you need to explicitly tell iOS to upload a file to iCloud Document Storage, which is what will allow files to appear in iCloud Drive on the user's devices.
So, I need to write some (iOS) code that utilise the FileManager class to:
Call the url(forUbiquityContainerIdentifier:) method in order to get the location of the local iCloud container and initialise it (at which point the app will appear in Storage & iCloud usage settings)
Tell iOS to upload the file to iCloud by calling setUbiquitous(_:itemAt:destinationURL:)
I'm building a very basic Cordova plugin to do this. I'll update this answer with a link when I'm finished.
Edit:
The cordova plugin I developed is called cordova-plugin-icloud-document-storage. It currently only implements uploading documents to iCloud (i.e. setUbiquitous), it doesn't implement the other iCloud functionality of the FileManager class (such as managing cloud updates or version conflicts). If anyone would like to develop this functionality please do submit a pull request.

Get call history programmatically in iOS 8

I am trying to get the call history programmatically on iOS 8 as an in-house app targeting jailbroken devices. This question had the solution.
Problem: Database directory has changed in iOS 8. Rather than
/var/wireless/Library/CallHistory/call_history.db
its now
/var/mobile/Library/CallHistoryDB/CallHistory.storedata
And if I use new database file on FMDB I get "permission denied". So far as I can tell its caused because sandboxed apps are logged in as "mobile" user and are not allowed to reach
/var/mobile/Library
Tried: Moving the CallHistory.storedata to old directory where call_history.db is located (as root). It works within the app that way. But I need my app to function on its own and copying files again are not permitted within app.
Is there any way I can let my app get permissions for /var/mobile/Library or any other solutions from experienced jailbreak developers?

JailBreak | Cannot access folders inside /private/var/mobile/Library

I am developing an app for Jailbroken iOS devices that access Safari history. History.plist file is placed at following path.
/private/var/mobile/Library/Safari/History.plist
I have successfully installed my app on jailbroken iphone by following tutorial
Use your jailbroken iPhone in Xcode for developing
When I try to access above path using fopen command of C, I can not access it. My code is below
FILE *fp = fopen("/private/var/mobile/Library/Safari/History.plist","r"); // read mode
if( fp == NULL )
{
NSLog(#"This file does not exist");
}else{
NSLog(#"This file exists");
}
It returns NULL file pointer.
I have Googled this and got to know that since my app is still in sandbox so I am not able to access above path. Couple of posts including [Why SandBox in iOS 6.1.1 still exists for App even after I have jailbreak?][2]
[2]: Why SandBox in iOS 6.1.1 still exists for App even after I have jailbreak? and [how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5][2]
[2]: how to get the message when receiving the "kCTMessageReceivedNotification" notification on IOS5 suggest that the app needs to move outside sandbox in order to access the complete file system.
I am confused about this. Can you please guide me how can I access this path?
Best Regards
Usually you will get a message in the console saying that access was denied. If the sandbox is indeed doesn't allow you to access browser history then you need to move your application outside of the sandbox. To do that you can copy your application into /Applications directory where all system apps are. You can do it using ssh, iExplorer or anything else that can access root folder of iOS device. Read this, the "The actual signing part" part. You can skip ldid stuff, you don't really need to sign anything unless you need to sign your app with entitlements.

Sencha Touch + PhoneGAP Build - iOS App rejected because of Storage setting

Experts,
Recently I've used PhoneGAP Build service for my iOS App (HTML5 App built using Sencha Touch), and when i submit to app store, they rejected my app with this reason
in particular, we found that on launch and/or content download, your
app stores non user-generated content in iCloud backup directories. To
check how much data your app is storing:
Install and launch your app
Go to Settings > iCloud > Storage & Backup > Manage Storage
If necessary, tap "Show all apps"
Check your app's storage
Is there any solution?
please help
I already have this app published in BB and Android with out any issues.
https://play.google.com/store/apps/details?id=com.pavan.cinetalk
http://appworld.blackberry.com/webstore/content/32189889/
I think PhoneGap Build might be setting BackupWebStorage by default to iCloud, if you set up PhoneGap locally this setting can be changed in the Cordova.plist file see the below link:
http://docs.phonegap.com/en/2.2.0/guide_project-settings_ios_index.md.html
If im not wrong the message is quite clear, they just don't want you to upload to their cloud data that is not generated by the user.
I don't know your app, but sounds like are you backing up things like images or media used by the application itself instead of user's data ¿?
#Brett Bailey: Thanks for your input, finally this parameter worked and iTunes approved my app now
https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=687594497&mt=8

Specific constraints of iOS sandboxing

I would like read access to the files in the iPhones music directory:
~/Media/iTunes_Control/Music/F**/*.{M4A,MP3}
1) I can't seem to figure out from the docs whether iOS apps are sandboxed such that I would or would not have this permission.
2) Is it necessary to ask for read or write permissions to directories outside the iOS App sandbox ? Only write permissions ? How does one do this, or is it just up to the discretion of the team that reviews the App for app store release ?
3) I have found a lot of information in the apple docs on sandboxing of OS X apps but not of iOS apps. Is there a similar sandboxing/entitlements process for iOS as for OS X apps ? Any useful links I should read ?
Update: as accepted answer says below, 1,2, and 3 are impossible, however it is possible to obtain a copy of a file in the media library, which is in some sense equivalent to having read access to the original - because of course the digital information is identical. This question contains code that does that:
Application crashed while importing songs from Ipod library in Iphone for iOs 5.0
You will not have permission to read/write outside your application.
You will not have permission to read/write outside your application.
You will not have permission to read/write outside your application.
You can use the Media Player framework to access information about the user's library, but nothing using the filesystem.
Sandboxing on iOS is done for you, there is no need to set that up.
You can not write files outside your applications sandbox.
I have not attempted to access music stored by the iPod app, but there is access to media types. It functions much like access photos.
Here is the link to the Apple docs for MPMediaPickerController.

Resources