I want to create folder in iPhone mobile (on my phone storage) using flutter,
i complete it in androids mobile but in iOS mobile i cant do it.
when i try to get the using getApplicationSupportDirectory() its return my mac storage path not the simulator storage path
if (!isTemporaryStorage) {
if (Platform.isIOS) {
var iosPath= await getApplicationSupportDirectory();
path = File('${iosPath.path}/Majd_Eng_folder/$fileName');
} else {
path = File('/storage/emulated/0/Majd_Eng_folder/$fileName');
}
Change the getApplicationSupportDirectory to getApplicationDocumentsDirectory for iOS. If you want to hide data's then try getLibraryDirectory
Note: Don't forgot to add permissions in info.plist
Related
I am updating one of our Cordova apps so everything is up-to-date for IOS and Android.
One of the things I ran into for IOS is the requirement that you have to ask for motion permission.
I was able to get the app to ask for the permission, but unlike the other permissions I am unable to customize the text.
The text is now as follows:
"localhost" Would Like to Access Motion and Orientation
But other permissions show the name of my app in stead of "localhost" and a description which I provided in the config.xml
I did provide a description in the config.xml and even added a description manually in the info.plist file in Xcode, but nothing helps.
I am using Ionic 6.9.2, Cordova 9.0.0 and added the ios#5.1.1 platform to Cordova.
Does anyone now how I can provide a description and fix the "localhost" in the Motion permission request?
maybe this is an old issue, but I hope this answer would be helpful.
you need to comment/remove on some block of code on leaflet.locatecontrol inside node_modules folder.
first go to node_modules -> leaflet.locatecontrol -> src and open file L.Control.Locate.js, then comment/remove following code:
if (this.options.showCompass) {
var oriAbs = 'ondeviceorientationabsolute' in window;
if (oriAbs || ('ondeviceorientation' in window)) {
var _this = this;
var deviceorientation = function () {
L.DomEvent.on(window, oriAbs ? 'deviceorientationabsolute' : 'deviceorientation', _this._onDeviceOrientation, _this);
};
if (DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission === 'function') {
DeviceOrientationEvent.requestPermission().then(function (permissionState) {
if (permissionState === 'granted') {
deviceorientation();
}
});
} else {
deviceorientation();
}
}
}
I am trying to add an image of a map generated by the google map static api in my Nativescript application (I'm using Nativescript with Vue).
I am able to make it work on Android but I have some issues on iOS.
I simply have an Image component like that <Image :src="map_source" />
And in my vue data, I have map_source: "https://maps.googleapis.com/maps/api/staticmap?&markers=48.2,2.1&path=color:red|weight:5|fillcolor:red|48.2,2.1|48.3,2.13|48.4,2.12&zoom=10&size=460x200&key=MY_API_KEY"
When I use this URL in my browser, I get the desired map.
When I use this URL in my app on Android, it displays the map correctly.
But when I use the same URL in my app on an iOS device, the map is not displayed at all.
Note: if I remove the path (e.g map_source: "https://maps.googleapis.com/maps/api/staticmap?&markers=48.2,2.1&zoom=10&size=460x200&key=MY_API_KEY", the image is correctly displayed on both Android and iOS. The error only appens when I add the path.
Is this an iOS issue or am I doing something wrong ?
I was able to find the issue thanks to #Manoj. On iOS devices, the URL was unsupported because of the "|" character. So I had to encode it like so:
let imageSourceModule = require("tns-core-modules/image-source");
let url = encodeURI("https://maps.googleapis.com/maps/api/staticmap?&markers=48.2,2.1&zoom=10&size=460x200&key=MY_API_KEY")
imageSourceModule.fromUrl(url).then(res => {
this.map_source = res;
});
I am trying to download a file and save that file in iOS. I am using ionic-native-file plugin to achieve this. The file has been download but i could not find that file in the device.
filewrite = (): void => {
let transfer = this.fileTransfer.create();
let path = "";
let dir_name = 'Download';
let file_name = "Sample.pdf";
if (this.platform.is('ios')) {
this.platform.ready().then(() => {
path = this.file.documentsDirectory;
this.file.writeFile(path,file_name,this.pdfSrc).then((entry) => {
this.showAlert("download completed");
}, (error) => {
this.showAlert("Download Failed.");
}).catch(err=>{
this.showAlert("Download Failed catch.");
this.showAlert(err.message);
});
}
)
}
};
Download completed alert shows and the downloaded path is:
file:///var/mobile/Containers/Data/Application/6DE22F30-5806-4393-830A-14C8A1F320BE/Library/Cloud/Sample.pdf
But i could not find that location in the device. Then, i google and saw here.
cordova.file.documentsDirectory - Files private to the app, but that
are meaningful to other application (e.g. Office files). Note that for
OSX this is the user's ~/Documents directory. (iOS, OSX)
So, i can't see the file actually as it is private to the application. Then i saw in the same link:
So, i tried with the both preference in my config.xml but nothing happened.
Is there any approach to download the file iOS or to dropbox or anywhere else?
I've struggled to find the right directory to save to on different platforms with this cordova plugin too. I landed on using file.externalRootDirectory on Android, and file.cacheDirectory on iOS.
The right location likely depends on what you intend to do with the file. In my case I just needed it stored short-term so I can open it using the user's native PDF reader.
I am using the Phonegap File API but am having trouble copying a file from one location to the other.
my targeted device is iOS(ipad)
my iOS version is 9.2.1
I am working on windows platform
I am using phonegap build
my requirement :
I am capturing a video and its getting saved in some temp folder by default here is the location where its getting saved (/private/var/mobile/Containers/Data/Application/2183897E-3660-4145-A822-76F5B763E48D/tmp/capture-T0x17e7cae0.tmp.avqBi2/capturedvideo.MOV)
So I just want to move this (capturedvideo.MOV) video to photo album location in my ipad
This is my code which i am trying to make it work.
function success(entry) {
console.log("New Path: " + entry.fullPath);
}
function fail(error) {
alert(error.code);
}
function moveDir(entry) {
var parent = document.getElementById('parent').value,
parentName = parent.substring(parent.lastIndexOf('/')+1),
newName = document.getElementById('newName').value,
parentEntry = new DirectoryEntry(parentName, parent);
// move the directory to a new directory and rename it
entry.moveTo(saveToPhotoAlbum, newName, success, fail);
}
Any help or working examples would be great.
Thanks
Nik`
This is simply not possible on iOS, because Apple does not allow to move videos, images or any other files out of the app sandbox to other folders. The reason that the standard-camera on the iPad/iPhone is able to place pictures there is simply because this is a built-in feature that has special permissions which your third-party app will not be able to get.
This is of course only true as long as the device is not jailbroken.
For more infos, especially concerning the file-system layout and what you are allowed to store, you should take a look at the cordova-file-plugin Readme on Github:https://github.com/apache/cordova-plugin-file
I have an application made in air in Flash Builder for iOS plataform
I've compiled a version and installed it on my iPhone, the app talks to the database but it does not write/update in database. What can be the problem? Permission of the device or the path of the database?
thanks for now.
code:
private var dbFile : File;
private var dbPath : String = "SAG.sqlite"; //name of database
private function setaAPP():void{
if(app == 'ANDROID'){
dbFile = new File('/mnt/sdcard/SAG/' + dbPath); // to ANDROID
}else if(app == 'DESKTOP'){
//app == DESKTOP
dbFile = File.applicationDirectory.resolvePath(dbPath); // to DESKTOP
}else if(app == 'DEBUG'){
//only to debug in Android
dbFile = File.applicationDirectory.resolvePath(dbPath); // to DEBUG in device
}else if(app == 'IOS'){
//app == IOS
dbFile = File.applicationStorageDirectory.resolvePath(dbPath); // to iOS
}
}
For iOS, I'm guessing you want this:
dbFile = new File(dbPath);
Though you could probably also use this:
dbFile = File.applicationDirectory.resolvePath(dbPath);
From Apple Documentation:
In an iOS application, nonlocalized resources are located at the
top-level of the bundle directory, along with the application’s
executable file and the Info.plist file.
The storage or "documents" folder is going to be empty until you write files there at run time (also via iCloud syncing).
If the structure is the same as your ANDROID or DEBUG projects (i.e. you included the db in the root application directory when packaging), you should be able to use File.applicationDirectory.resolvePath(dbPath) just as you did in those cases.
EDIT:
The app directory is not writable, so if you want to write to the database, you will need to move the file to the Documents directory, which you can access with var docs:File = new File(File.userDirectory.nativePath + '/Documents');