Facebook iframe automatically opening in safari... yes I've read the docs.

356 views
Skip to first unread message

subrock

unread,
Aug 31, 2011, 5:26:01 PM8/31/11
to phonegap
okay, so after a few days of banging my head against the wall I need
some help.

I'm trying desperately to get the iframe version of a facebook like
button to work in my app but I keep having the page automatically
redirect to safari.

I've read the official "add url to external hosts" line in the FAQ and
I'm still getting a redirect. see: http://i.imgur.com/sJCWX.png

I have added a few lines to appDelegate.h to allow clicked URLs to
open in google maps and safari and I wonder if maybe that is causing
the problem.

<code>

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:
(NSURLRequest *)request navigationType:
(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];



// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:@"http"] || [[url scheme]
isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request
navigationType:navigationType ];
}
}

</code>

Can someone tell me what if anything is missing from my external hosts
entries or possibly what might be causing my suffering.

thanks!

James Ferguson

unread,
Aug 31, 2011, 5:30:34 PM8/31/11
to phon...@googlegroups.com
The problem is not the app, Facebook does not allow iframes or frames to view their site inside. They have scripts that force it to break out. If you add the plist urls in, the iframe will show blank as facebook will not allow content inside fames.
 
Thanks
James f.

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com



--
Sincerely,

James Ferguson
UX Manager
Seal Innotech
C: 208.964.5086
E: James.f...@sealinnotech.com
 
Don't miss LIVE DEMOS of our new SAP MOBILE APPS
SAPPHIRENOW  BOOTH #2436  |  MAY 15-18  |  ORLANDO 
SAP Pinnacle Awards 2011 Finalist

Featured in
SAP InsiderPROFILES Changing the Enterprise Mobility Game

subrock

unread,
Aug 31, 2011, 5:34:32 PM8/31/11
to phonegap
facebook gives you iframe code to run their like button in one of 2
suggested ways: https://developers.facebook.com/docs/reference/plugins/like/

are you saying this somehow doesnt jive with phonegap? I've
implemented an iframe like button on the web with no problems.



On Aug 31, 2:30 pm, James Ferguson <james.fergu...@sealinnotech.com>
wrote:
> E: James.fergu...@sealinnotech.com

Shazron Abdullah

unread,
Aug 31, 2011, 5:38:30 PM8/31/11
to phon...@googlegroups.com
The end result is, for that logic flow, you need to return YES when it encounters the iframe url so that it loads in the PhoneGap UIWebview. Try to put in debug statements to see the BOOL value when that happens (and the other values, and navigationType).

James Ferguson

unread,
Aug 31, 2011, 5:47:54 PM8/31/11
to phon...@googlegroups.com
I guess I am un aware of their iframe code. So perhaps im the wrong guy to answer. I had tried to use my facebook page just two months ago and their support said they dont allow it. So any info you have may be newer.
 
Thanks
James f.

subrock

unread,
Aug 31, 2011, 5:56:07 PM8/31/11
to phonegap
hey Shazron,

I'm not well versed in obj c and I'm mostly trying to adapt what
solutions others have given. are you saying that the problem is with
the code I changed in app delegate?

would an if statement to break out and return yes if the url matches
the iframe src be the logical solution?

I tried this (and variations) before the "return NO;" statement with
null effect:

if ([[url scheme] isEqualToString:@"http://www.facebook.com/plugins/
like.php"]){
return YES;
}





On Aug 31, 2:38 pm, Shazron Abdullah <shazron.abdul...@nitobi.com>
wrote:

Shazron Abdullah

unread,
Aug 31, 2011, 5:59:34 PM8/31/11
to phon...@googlegroups.com
well, that's not the root of the problem - but for now we're trying to isolate your problem, and find a workaround. I modified your code - try this:

if ([[url description] isEqualToString:@"http://www.facebook.com/plugins/
like.php"]){
return YES;
}

The problem it seems is that somewhere down the line, it is returning NO for your iframe url.

subrock

unread,
Aug 31, 2011, 6:07:55 PM8/31/11
to phonegap
I just tried it with that code and I'm seeing the same result. when I
revert the code to the stock bool statement:

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:
(NSURLRequest *)request navigationType:
(UIWebViewNavigationType)navigationType
{
return [ super webView:theWebView shouldStartLoadWithRequest:request
navigationType:navigationType ];
}

the page loads without switching to safari, but the iframe never gets
rendered.




On Aug 31, 2:59 pm, Shazron Abdullah <shazron.abdul...@nitobi.com>
wrote:
> well, that's not the root of the problem - but for now we're trying to isolate your problem, and find a workaround. I modified your code  - try this:
>
> if ([[url description] isEqualToString:@"http://www.facebook.com/plugins/like.php"]){

subrock

unread,
Aug 31, 2011, 6:11:15 PM8/31/11
to phonegap
for reference this is the iframe code:

<iframe src="http://www.facebook.com/plugins/like.php?
app_id=159894190758643&amp;href=www.facebook.com&amp;send=false&amp;layout=standard&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=35"
scrolling="no" frameborder="0" style="border:none; overflow:hidden;
width:150px; height:35px;" allowTransparency="true"></iframe>

Jesse Macfadyen

unread,
Aug 31, 2011, 7:47:25 PM8/31/11
to phon...@googlegroups.com
In that case, your isEqual test returns false, u need to test using
host=Facebook.com, or index of

Cheers,
Jesse

Sent from my iPhone5

subrock

unread,
Sep 1, 2011, 1:26:36 PM9/1/11
to phonegap
tried with facebook.com in external host in phonegap.plist and in
appdelegate.m with no luck.




On Aug 31, 4:47 pm, Jesse Macfadyen <jesse.macfad...@nitobi.com>
wrote:
> In that case, your isEqual test returns false,  u need to test using
> host=Facebook.com, or index of
>
> Cheers,
>   Jesse
>
> Sent from my iPhone5
>
> On 2011-08-31, at 3:11 PM, subrock <hoar....@gmail.com> wrote:
>
>
>
>
>
>
>
> > for reference this is the iframe code:
>
> > <iframe src="http://www.facebook.com/plugins/like.php?
> > app_id=159894190758643&amp;href=www.facebook.com&send=false&layout=standard&width=150&..."

Shazron Abdullah

unread,
Sep 2, 2011, 2:08:32 AM9/2/11
to phon...@googlegroups.com
No, what Jesse is saying you need to test the equality of [url host] with "facebook.com"

subrock

unread,
Sep 2, 2011, 12:53:34 PM9/2/11
to phonegap
ah ha, that got it.

for anyone else reading this with the same problem:

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:
(NSURLRequest *)request navigationType:
(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];

if ([[url host] isEqualToString:@"www.facebook.com"]){
return YES;
}

// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:@"http"] || [[url scheme]
isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request
navigationType:navigationType ];
}
}


now to figure out why the iframe isnt rendering.

thanks guys

On Sep 1, 11:08 pm, Shazron Abdullah <shazron.abdul...@nitobi.com>
Reply all
Reply to author
Forward
0 new messages