iPhone/Objective-C - UIDocumentInteractionController Class Reference when presenting a view and delegates - iphone

I am using UIDocumentInteractionController inside my application in order to present the Instagram filter screen as described here from within my application:
http://instagram.com/developer/iphone-hooks/
UIDocumentInteractionController Class Reference documentation:
I'm not quite sure whether it's possible to dismiss the Instagram filter screen and return back to my application with the modified UIImage after it has been uploaded (or maybe after it's been filtered) by Instagram.
As far as I know I don't think this is possible, as there's no delegate method that's available once an application has been spawned and this would most-likely involve a dismiss button from within the Instagram filter screen.
Either way, I'd also like to know whether there's a suitable way to at least return the URL/ID from Instagram once it's been posted so that I can reference the modified image from inside my application using either their API documentation or by just referencing the image url.
Thanks in advance and any help would be greatly appreciated.

My understanding from reading the material you provided is that using UIDocumentInteractionController to do this actually opens Instagram and switches to it. If that's true, then the only way to receive a callback or any kind of information from Instagram would be if they supported it explicitly. I encourage you to ask them by email (contact#instagr.am) or on the Google group (perhaps you already did?).
(If they did support it, I'd imagine you might be able to call up Instagram with a URL like instagram://[regular options]?callback=myapp://callback_url, which they would then open when finished.)

Related

(Freshplanet Facebook-ANE) How to make the login screen in-app

I am currently using the Freshplanet Facebook-ANE and was wondering about something that is bugging me currently.
I want to implement a simple post to wall feature inside my app, and this ANE does exactly what I want, except for one thing. When I do the actual post to wall dialog, it pops up just like I want it, in a WebView inside my app. The login takes me to Safari or the Facebook app if I have it installed, which is what I want to avoid.
Here's the line I'm using to open the session :
Facebook.getInstance().openSessionWithPublishPermissions(POST_PERMISSIONS, OnSessionOpened, true);
That works perfectly for posting, but takes me outside of the app.
I've tried using the same .dialog() function I use for the post, and it worked, but I can't seem to post to the wall afterwards (maybe I'm not correctly catching the access token or something)
Any help would be appreciated. I believe I've set up everything correctly on my Facebook App page, and that my AS3 project is correctly setup.
Thanks for the help !
If you want to strictly stay into the app, you must use StageWebView. It's something like a wrapper of HTML page inside Flash.
First check if you are logged in (this is code from Facebook.as of FreshPlanet):
/** True if a Facebook session is open, false otherwise. */
public function get isSessionOpen() : Boolean
{
if (!isSupported) return false;
return _context.call('isSessionOpen');
}
If there is no session - start the web view. Otherwise - continue as usual.
You have to keep in mind that StageWebView is pretty.. how to say it.. bad is the kindest thing I could say :) You must implement your own close button, listen for url changing, etc.
You could look into Facebook AS3 SDK, which at least has some kind of 'platform' for the web view..
Good luck!

Open Url handling

I have a problem that I am opening the "http://itunes.apple.com/in/app/eft-feel-happy-fast/id474157386?mt=8" type of url on a table view didSelectrowIndexPath, then app store open and user can download my app but the problem is that I want to go back to my application from the app store how is it possible can any one help me?
Thanks in advance.
If you open safari and leave your app, you cannot control what happens next. The user will return to your app when he/she chooses to.
Don't use default browser of device,you can't come back from that. For this create new class and use webBrowser. By the help of this u stay in you app.....
You can use SFSafariViewController class to redirect the links within your apps and make sure that the user doesn't leaves the app. Here is a tutorial on how to do it.
SFSafariViewController Tutorial
PS- It is written in swift.

How to take a screenshot of a website

I am building a web browser for iPhone in Xcode and the "home page" of my app is a speed dial page which provide 6 slots for users to add their favorite website. Each slot will then display a screenshot of the website. So what I want to do here is to grab the screenshot from the link input by users, for example, "http://www.google.com". Is it possible to do this with cocoa touch?
In case anyone want to have a similar function like this, I did find a way to do it but not sure whether it's the best way of doing it. Or maybe now there are libraries or plugins out there that provide this function already.
My solution
After users have entered a website url, you need to create a temporary UIWebView and load the url (do not make it visible to the users). After the UIWebView finished loading, you make the UIWebView visible and then take a screenshot, after that, make the UIWebView invisible again immediately (or simply destroy it). In this case, you will get the screenshot of that website and users won't notice what just happened.

titanium webview - go to default browser when clicking links

in titanium, i'm using the webview to display a wordpress blog page, that is already formatted for mobile browser. instead of writing my own interface, this works as a good work around. the apps sole focus isn't the browser.
but my issue lies, when the user clicks a link outside of the initial displayed domain. i only want the main domain to be displayed in the apps browser. if any other link is clicked, that takes the user outside of that domain, i want to have it open in the phones default browser.
can anyone point me in a direction for this. i tried adding a listener to try and catch link clicks, however, i've been unsuccessful.
thanks
in this blog posting I show how to find links in a webpage and change the link behavior. Using the same method, you can intercept the links and redirect to opening the URL in the devices default browser
One solution would be to catch the onclick() Event by Javascript inside the WebView (your blog code) and handle this by a custom handler. Maybe you can inject the javascript event handler code into the running WebView through Titanium.
Another solution is to make your blogposts readable for app technology and create a new data interface. This is the way I would do. For that I would use some kind of JSON data format and a simple REST Interface to get the data.
I don't think bove solutions are that simple. If you want an app with "great feeling", you'll have to handle the events by your own. Maybe Phonegap would be a better solution four your problem. But there you will still need a kind of REST/JSON interface for your blog data. The idea behind an app is, that the main code is in your app and you get the content from a remote source. This way you'll get an advantage compared to a simple browser optimized site.

How does facebook's Share a link feature work?

I'm trying to implement a feature like that where a user inputs a url and when displaying that url I want to have a custom display (an embed object if it's a video from youtube, a thumbnail if it's an image link, title and excerpt of body if it's a normal link).
How can such a feature be realized?
There is a new idea called oEmbed that a few sites support (Flickr, Vimeo and a few others) that addresses this problem. oEmbed site
Otherwise, just check the site against a list of ones you pick and then pull out the relevant bits to construct an embed link.
I liked the idea of oEmbed a lot but unfortunately it doesn't has that much adoption yet.
oohEmbed tries to solve this issue by building oEmbed for many websites.
For the feature to work, it needs the server's interaction where I believe the following scenario is how it works
Assume that we have the site humanzz.com and that it provides such feature
A user enters a url on the humanzz.com's webpage and presses a button like facebooks' preview button
An AJAX call is made to a dedicated page on humanzz.com
humanzz.com does calls the remote website and gets its data
The AJAX call now returns the page's data (oEmbed JSON object)
This involves so much server's overhead.
I really wanted to do it using JavaScript as the server's role was only to bypass "Same Origin Policy"'s restrictions.
oohEmbed allows bypassing the server's step by specifying a callback parameter to oohEmbed so that the JSON object returned is passed to a callback function on your page.
An example illustrating this is as follows
Add a script tag dynamically to your page
< script type="text/javascript" src="http://oohembed.com/oohembed/?url=http%3A//www.amazon.com/Myths-Innovation-Scott-Berkun/dp/0596527055/&callback=myCallBack">< /script>
This would result in executing myCallback(oEmbedJSONObject) which is great.
The problem with that solution is you still have to have a fallback for websites that don't have oEmbed representations.
For the embedded things, I have been using auto_html ( https://github.com/dejan/auto_html) with great success (vimeo, youtube, images) and even added soundcloud myself. But I am still looking for a "thumbnail" generation with an image and text facebook-like.
I guess you have to construct it by yourself by manually parsing the kind of URL you get.
If it is an image url, well then you just have to rescale it and in case the user clicks on it, then handle that by opening the original one somehow.
If it is a link to some youtube video, then you have to take a look at how the embedding of Youtube videos works. You can just copy the code that is provided by Youtube itself, and then exchange the parts with the URL to the video with the URL you got from your user.
I did never implement something like that, but I assume it should work somehow like this.