summary in short: edge.create stopped firing in embedded HTML inside UIWebView (and I did not change anything in code for a while) – any ideas how can I get it back?
I have iOS application which has UIWebView with Facebook Like button.

User logs into Facebook BEFORE this dialog appears, so there is no login logic happening.
I can click like/unlike – and it works fine – but it used to close the dialog, and few days ago this broke. Closing the dialog was achieve by subscribing to edge.create / edge.remove events.
Here is my HTML page:
<html>
<head>
<style type='text/css'>
* { -webkit-touch-callout: none; -webkit-user-select: none; }
body { margin:0px; }
.fb_edge_comment_widget { display: none !important; }
</style>
</head>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js#xfbml=1'></script>
<script>
function forwardEvent(name) {
var iframe = document.createElement('iframe');
iframe.setAttribute('src', 'event:' + name);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
};
function beginForwardingEvent(name) {
FB.Event.subscribe(name, function(r) { forwardEvent(name); });
};
function beginForwardingEvents(names) {
for (var i = 0; i < names.length; i++) {
beginForwardingEvent(names[i]);
}
};
beginForwardingEvents(['edge.create', 'edge.remove', 'xfbml.render']);
</script>
<fb:like href='%@'
send='false'
layout='%@'
width='%.0f'
show_faces='%@'
action='%@'
colorscheme='%@'
font='%@'
></fb:like>
</body>
</html>
and here is how i capture events in Objective-C code:
- (void)didObserveFacebookEvent:(NSString *)fbEvent {
if ([fbEvent isEqualToString:@"edge.create"] && [_delegate respondsToSelector:@selector(facebookLikeViewDidLike:)])
[_delegate facebookLikeViewDidLike:self];
else if ([fbEvent isEqualToString:@"edge.remove"] && [_delegate respondsToSelector:@selector(facebookLikeViewDidUnlike:)])
[_delegate facebookLikeViewDidUnlike:self];
else if ([fbEvent isEqualToString:@"xfbml.render"] && [_delegate respondsToSelector:@selector(facebookLikeViewDidRender:)])
[_delegate facebookLikeViewDidRender:self];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
// Allow loading Like button XFBML from file
if ([request.URL.scheme isEqualToString:@"file"])
return YES;
// Allow loading about:blank, etc.
if ([request.URL.scheme isEqualToString:@"about"])
return YES;
// Block loading of 'event:*', our scheme for forwarding Facebook JS SDK events to native code
else if ([request.URL.scheme isEqualToString:@"event"]) {
[self didObserveFacebookEvent:request.URL.resourceSpecifier];
return NO;
}
....
}
so once again – edge.create stopped firing (and I did not change anything in code for a while) – any ideas how can I get it back?
Thank you.
UPDATE:
though there is a FB bug reported, i still would like to understand why it does work on FBRELL site but does not work inside iOS UIWebView. May be there is a tweak required for iOS dialog? Is there a workaround for this? Started the bounty hoping to get an answer.
It seems that the edge.create event won’t fire within the local HTML file. Whether this is by chance or design, I’m unsure, but I’ve done a few things and got this to work:
Hosted the ‘FacebookLikeView.html’ file on my own server, substituting the format specifiers for the actual values i want, e.g.
action='%@'is now explicitlyaction='like'.Removed everything from the
loadmethod in FacebookLikeView.m and replaced it with the line:Changed the line in the
webView:shouldStartLoadWithRequest:navigationTypemethod:to
It’s not the answer you were hoping for, but I hope this gives you some clues, and at the very least helps to get it working in the meantime.