I´m downloading a file to a SD card in the BlackBerry, and when I open that file, my application run. So when my application run, I need to delete that file.
The problem is that I dont know where it is(the file) from my app, because the user could download that file anywhere.
Is there something in the BB OS that let me know the path of that file? With this I can give to my app a parameter or something...
Well, thats it.
If you register with invocation registry so that your app is invoked whenever file needs to be opened, you will get full URL in Invocation object. This URL is sufficient to delete the file via FileConnector.
See this BlackBerry example to properly register your app. Also, in step 6 note invoc.getURL() - this is what you need to use.
Related
I have been trying to access a file with my share extension, if the file is from photos app, I can access it, the path for the file is:
file:///var/mobile/Media/PhotoData/OutgoingTemp/11485686-0D4A-4637-AA50-B14D83E18B01/RenderedPhoto/IMG_4807.JPG
but when I try to access a file on the "private" path, I cannot access it, like an MS word file:
file:///private/var/mobile/Containers/Data/Application/196D7E75-87B6-4C69-B97A-74E58DF4AD65/tmp/ShareAttachments/%7BE73A233D-D10E-814D-AEB1-0C8C8AC9BFAA%7D/Document%20(7).docx
So my question is, how to access the file? apps like whatsApp or slack can have access to the file and attach it...
How to access this file? are they using "app groups"? how do they get the id for the app group? or how to access the file?
For Share Extension, you need to get the file from NSItemProvider, which is passed by the host app to your share extension.
For a file, it may be a Data type or a URL type. If it is data, you need to cast it to the type you need. If it is a url, you can load it.
Please follow the given link:-
https://developer.apple.com/app-extensions/
Thank you.
Shriram
I'm very confused. I want to store few user files, but not docs. I'm using:
static var directory: URL {
get {
return FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask)[0].appendingPathComponent("Caches").appendingPathComponent("OnlineFiles")
}
}
Always the same. Every time I launch the app I get different URL.
Am I doing something wrong? Is there some magic switch in project file which I need to set?
Once it's something like:
file:///var/mobile/Containers/Data/Application/4547EF22-EB33-4B65-9772-67ED7870E3E9/Library/Caches/OnlineFiles
Other time it's:
file:///var/mobile/Containers/Data/Application/83C8CDD7-B4D0-48B2-8A8E-9BD48C5D1754/Library/Caches/OnlineFiles
This string between /Application/ and /Library/ seems to be random. How to store files in one location when I can access them later when opening app second time?
[EDIT]: how to get path which is not changed every time I update app?
This is apple's security mechanism.Every time you restart the APP, apple sandbox path of APP to encryption, to prevent access to other programs.The encryption keys inside the APP.So before the end of the program, no matter where to access the APP sandbox, return to the path are the same.If you want to know more, you can look at apple's sandbox mechanism.
I've saved a file locally and want to open it in Word if installed. For example my file's URL is:
file:///var/mobile/Containers/Data/Application/{guid}/Library/Caches/MyFile.docx
My Office URL is:
ms-word:ofe|u|file:///var/mobile/Containers/Data/Application/{guid}/Library/Caches/MyFile.docx|p|my-protocol
When Word launches it says:
The link you clicked on is invalid and the document cannot be opened
However if I feed the original URL to a UIDocumentInteractionController it opens correctly.
Any ideas?
If you pass the URL to Word directly you are attempting to violate your Application Sandbox - Word doesn't have access to your App's directory, so it can't read the file.
You have to use the UIDocumentInteractionController to prompt the user to open the document in Word or you need to store the document somewhere that Word can read it (this would be external to your device - on a cloud store somewhere)
Suppose I am making a server call using NSURLRequest and NSURLConnection. I am making call to URL such as "http://www.testAAA.com.au/methodName". Now user installed my App. Few days later, I needed to change base URL. For example: "http://www.testAAA.com.au" to "http://www.testBBB.com.au".
In short, just base URL is being modified. I need to set such a mechanism that once server base URL changes, App can update base URL in the next call made for device. I have taken a constant for base url. So, next time the App makes any call to old base URL, I need to update that base URL with new one.
Is there any trick I can use?
Suppose you have const NSString *baseURL; in your Constants.h file, then in didFinishLaunchingWithOptions you can set your baseURL with the new one, this will update the url when user restart the app.
A common practise is to have a remote config endpoint that supplies a config file of some flavour (plist/json/whatever) that is downloaded at application launch.
Launch app.
Download remote config file.
Configure app with remote config.
Enjoy soft endpoint configuration.
It does rely on you having a constant config endpoint for any given app version but does mean you can change API endpoints at will.
Is there any difference between creating a direct link to a file on a server, and doing something like reading the file from a location and setting the content type header then streaming back the data.
I'm curious because I have a webserver that i'm using to download apps to a blackberry, if i create a file and have a direct link to that file it works, but if i stream it back using an webpage it doesn't work. The phone gets the file but it doesn't work.
Things to note:
urls are the same in both cases ie (http://somesite.com/download/file.jad)
in a browser using fiddler the downloads/header are exactly the same byte for byte
So why would the phone prefer a file that's actually a direct link vs one that is a controller streaming the data back when the data transmitted and the url are identical?
The .JAD file is just the first part of the download - there are also the .COD files associated with it (referenced in the JAD). Did you ensure that your "streaming" method is sending back the COD file correctly and with the correct MIME types?
I discovered a fix for this problem though I'm still not sure what causes it. I have been delivering the link to the phone through the sms/email gateway. When the phone gets the sms and I select the link for download it asks if i want to get the jad i hit yes and it shows up and drop out. I put the exact same link on another page as an html link and sent an sms pointing to that page. The web site throws an error... So I copied and pasted the link into the phones browser and the page shows up just fine, I click the jad download link on the page and now the jad works fine.
So i'm thinking two things either there is some sort of security mechanism that prevents direct links in sms(but this has worked for other files) Or the way the phone gets the url is different.
I ran some tests and noticed something else, on a page that accepts an id value (http://site.com/download/145) where 145 is an id for a file, if you go to that link in a phone browser it works fine and you download the file. If you send it in an sms the server errors out saying that the id is expected to be a float and it received a string. So why is it that when the phone links directly from sms the url parameters are strings but when used in a browser the actually get parsed as a float?
Sorry for the long winded explanation but it's a strange issue.