Simplest way to incorporate iPhone file upload when building app with Appcelerator's Titanium Developer - iphone

Sorry for the long explanation. Thanks in advance to all who are taking their time.
I am an Ubuntu user who has set up Titanium Developer on a MacMini in order to build an app for the iPhone (and ultimately some other platforms).
Rather than having any local code built in, the app simply points to my website. To do that, all I needed to do was change Titanium's tiapp.xml file to include my website URL. I wrote no other code, nor did I need to include any other files. It simply compiled and ran in the emulator without a hitch.
I've got just one problem: I need to upload files to my website and Apple, as most of you know, has disabled the input field type=file. I've got it working in all other browsers. The action simply calls a php file and passes the file info.
If I didn't have an app, and someone was just manually navigating to my site with the iPhone's Safari browser, I could get around the problem by using CliqCliq, which is a very cool iPhone app. Basically, I use JavaScript window.open() to launch CliqCliq's QuickPic browser in a second Safari window. The user chooses a file; QuickPic uploads it; and the user is returned to the second Safari window that I launched with window.open(). The user closes the window and Safari returns them to the first window (i.e., my website).
The problem is that my website is being shown in my app. (By the way, I don't have my developer license yet, even though I signed up a few weeks ago, and I can't test this in the emulator because I can't install QuickPic into it, I assume.) I wanted to repeat the same steps, described in the previous paragraph, using an iFrame but that didn't seem to work (i.e., the iFrame was blank despite my designating a src). I also tried having a hidden window by using old-fashioned frames and setting the col-width to 0. That also did not work (i.e., Safari, if I recall correctly, opened a separate window).
I'm working a little blind, since I can't test anything on the iPhone, but I figure I have two options: I can either find a way to launch a QuickPic in an iFrame -or- I can find some way to incorporate the Apple toolkit file chooser into the Titanium app.
The problem with the first option -- but again, I don't know until I can try this on the iPhone -- is that I assume both apps (mine and CliqCliq's) could not run at the same time. Even if I had a hidden window, invisible iFrame, etc., the moment it launches QuickPic, I assume my app would quit(?).
The problem with the second option is that I don't have clue as to how to incorporate a file picker into my app by using Titanium (keeping in mind, everyone, that I know very little). Brian at CliqCliq has even offered to give me some code if I can't make Apple's file picker work but again, I'm not sure what to do next.
What do you folks think? What's the best method? And, what's the easiest thing for a simpleton to do?
Thanks.

<input type="file"> is not supported on the iPhone. You'll need to use Titanium's APIs, specifically the Media one (openPhotoGallery or showCamera).
As a side note, Apple reportedly rejects apps that are just a webview displaying a website. You may want to consider putting most of the app code in local storage and using AJAX to fetch content.

Related

Register app to open from Safari's "share" or "open in..." dialog not working. (though works from other apps)

I am trying to register my application to show up in Safari's "Open-in..." dialog when a user clicks the share button on any html webpage.
I have added the public.html (and public.data for good measure) content types to the Document Types in Xcode, as suggested in many answers: (See this question, this question, or this apple documentation.)
And, it seems to work. If I open a .pdf in Safari, I get the "open in My App" dialog at the top.
I can also use the "open in..." dialog from other apps to share the document with My App.
To test it, I built DocInteraction as recommended in this answer, and if I create an html file, My App shows up in the share dialog.
However, My App still doesn't show up in the share dialog in Safari.
When I run it in iOS7 on the iOS Simulator, I only get Mail, Twitter, and Facebook showing up:
The same goes when I test it on my real iOS device:
BUT, I would like you to note that it does seem to be possible! Look at the above screenshot.. SOMEHOW, Weibo has managed this feat. I don't know how, but for some reason Weibo shows up in this list even though My App doesn't.
And you know, actually, this sort of makes sense, given how many apps can probably open html pages. Here is DocInteraction running on my iOS device trying to share an html page:
There it is! My App! (It's actually called "Wulu Podify"). But there are so many apps who are hungry for .html pages, I guess Safari thinks it might be a bit overwhelming to provide them all.
BUT, this still begs the question, how did Weibo get themselves on that list? But, some further digging seems to show that actually Weibo seems to have gotten itself on EVERY list.
I'm not sure how they managed it, but maybe they are going about this differently.
Weibo's "I-will-open-any-document-you-throw-at-me-c'mon-try-it-c'mon" approach might solve this problem, but it's not ideal. I really only want to open html pages.
So. I guess my questions is three-fold:
Is there a way to actually have my app show up in Safari's "Open In..." dialog?
If not, how can I achieve what Weibo achieved, and show up in ALL the dialogs?
Should I want to do that? It seems like it might be a bad idea.
Thanks for any help! I've been at this for a while!!
Update:
So, actually, I didn't realize it but I think Weibo might be a built-in option just like Facebook and Twitter. I assumed it was just there because I have it installed on my phone, but maybe it was one of the iOS6 defaults. I say that because when I test on the iOS6.0 Simulator, I suddenly see Weibo show up in the share screen, even though I definitely haven't installed it on my simulator.
So maybe there is no way around this except for having it built in to Safari by apple..
I know this is years later, but if anyone runs into this old question, as of IOS 8, Apple now allows app creators to make "extensions" which do allow you to add your app to the share menus.
Here is some documentation:
https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html
I fear what you want is not possible.
There is a difference between the Share dialog and the Open With dialog.
For the latter it's possible to register your app with document interaction, but the Share dialog only provides the native types (which Weibo is one of - see here: UIActivityViewController).
Also see this question on StackOverflow: is-it-possible-to-add-an-app-to-the-native-share-dialog
its , called extension , fist create a new project and than -->
file ->new -> target -> application Extension -> ####
and select your required extension and done....

IPhone Safari 302 Redirects open new windows

I have a fairly standard ASP.Net web application which is used via mobile safari on the iPhone.
Some users who have a link to the web application placed on their desktop via profile are reporting that when navigating between pages (which I do on the server with Response.Redirect after specific events or via standard anchor tags in other cases (no target specified)) that Safari opens a new window instead of reusing the existing window.
Because of this, any login token/cookie etc (i'm using the built-in ASP.Net membership stuff), is now gone for that new browser window and the login prompt is shown.
The problem doesn't happen every time, and I can't seem to replicate it on my device (but i'm not deploying the shortcut via profile)
As you can probably imagine, it's quite frustrating for the users to have to log in every time, and you can't fix an issue you can't replicate.
My question is, has anyone heard of this issue and/or know a workaround?
The app is NOT iPhone specific, that is, it is used in a full desktop browser as well, and the logins stay like you'd expect there - and the same window is reused repeatedly.
I've considered a few possibilities, but have been drawing a blank as far as what might be causing this or how I can resolve it.
Do you have any iPhone meta tags set (to remove the url bar or the toolbar, for instance?) If you do, the phone will assume it's a native web app, and urls will open in a new safari window, like they would for any other native app.
If you are taking advantage of using the web app in full screen mode (where it is bookmarked to the launch screen next to native apps) you can prevent it from jumping out of fullscreen mode by and in to safari replacing type links with javascript.
location.href = '/yourPath';
This is a nifty trick which even works if you are linking to an outside URL, like doing an OAuth to Facebook and back.
I have a blog post on this here: http://www.aaroncoleman.net/post/2011/07/29/Keeping-iPhone-Web-App-in-Fullscreen-mode-from-Homescreen-Launcher.aspx

Can UIWebView replace a Safari?

Can we build an Application using UIWebView that will entirely mimic the Safari Browser?
Are there any cases where UIWebview can not do what that can be done in Safari?
For one thing, you have a separate cookie storage per app. So if a user has some preferences at site X within Safari, it won't have those preferences at site X within your browser, and vice versa. Apart from that a UIWebView is very much like the real thing.
You cannot easily build an application that mimics the Safari browser using the public API exposed by UIWebView component. For one thing, please look at the UIWebView delegate methods. When you have frames inside the page you want to load, you may have a hard time telling if a user has clicked inside an iframe/frame or clicked on a link in the main document.
Dealing with authentication to site with invalid certificates is also hard with the UIWebView component, especially when the site with invalid certificate is reached by clicking a link inside an iframe.
Rendering content in UIWebView will be much slower than it is in Safari.
Safari's Javascript engine uses a "just in time" compiler. It takes the incoming Javascript code and transforms it on the fly into machine code that can run directly on the iOS device's ARM CPU. This allows Javascript code to run at a speed similar to a native app's code.
The problem is that Apple doesn't trust third-party developers with this power. If a third-party app had the power to convert Javascript into machine code and run it, that app would also have the power to download and run other pieces of machine codeā€”and Apple would never get the chance to review that code. Once App Review approved it, (developers/hackers) can change the downloaded code into something that logs your passwords or something. And there's no way to grant this power only to UIWebView and not to other parts of an app, because UIWebView runs in the same process as the developer's code.
So basically Apple forbids this because allowing it would break the security provided by the App Store and make iOS more vulnerable to attack. They can allow it for Safari because they control what Safari does, but they can't trust others not to abuse that ability.

iPhone code browser?

I want to be able to read code on my iPhone in the bus every day. Ideally, I'd like to be able to download a package, extract it to a folder, put it on the iPhone, and be able to just browse through the code (folders & files and all). Don't need to be able to edit, just read.
Is there a good solution for this? If there is not, could it be a good first project to teach myself iPhone development? or would it be too big a chunk for a first bite? (right now I mainly just do python web app development)
Thanks!
Check out the Airsharing app. When you run the app, it creates a server on your network (when sharing is enabled) and provides you an ip address you punch into a browser. You then upload files to the device via an ajax interface. Later on, you just open up the app and click the file you want to read and it displays on the screen. I've fiddled with it and it does preserve code highlighting.
You might also check out the new MobileMe iDisk app that just got released today. It looks like a slick way to share files between the iPhone and a Mac (and the cloud). You need to be a MobileMe subscriber, though.

iPhone app that access the Core Location framework over web

I was wondering if I could access the iPhones Core Location framework over a website?
My goal is to build a webapp/website that the iPhone would browse to, then upload its current GPS location. This would be a simple site primary for friends/family so we could locate each other. I can have them manually enter lng/lat but its not the easiest thing to find. If the iPhone could display or upload this automatically it would be great.
I don't own a Mac yet (waiting for the new Mac Book Pro) but would like something a little more automatic right now. Once I have the mac I could download the SDK and build a better version later. For now a webapp version would be great if possible. Thanks.
Why not simply use W3C GeoLocation API available in mobile Safari? This will work on ipod touch as well (suburb precision).
It's literally 10 lines of code and the javascript will work without change on Firefox 3.5. Far easier than scrape some third party website.
http://www.instamapper.com/iphone
iPhone App store
While this may not directly answer your question, there are quite a few iPhone apps that already do this kind of thing with GPS. Instamapper is the first one I pulled up from the app store, but I'm sure you could find something to fit your needs.
I'm pretty sure you can't do what you want directly.
The best idea I can come up with is to "reuse" an iPhone app that records location and makes it accessible on the web. Take Twitter for example. If I'm not mistaken, Tapulous' app Twinkle will grab your location and post it to your Twitter.com user profile. Here's an example of what that looks like:
From your webapp, you could then scrape the user page for each person whose location you're interested in. It's a pain in the butt, but like I said, this is the best I could come up with.
Again, if you don't want to mess with Twitter, there may be other apps out there that do this as well, but I don't personally know of any. Good luck.
We built a really thin iphone client app that simply calls a predefined .js file on our site. Works like a charm.
See arisgames.org for the project.