Facebook iOS SDK - Strange Effects in Writing to Status - iphone

I'm updating my app to use xCode 4, iOS5 and the latest Facebook SDK. All was working fine before.
Now, two strange things are happening and despite reviewing all the code and searching the forums, I can't see why.
See update below.
Logging in for first time
When the user has just logged in, if they either share the status or cancel the attempt to do so, a script is displayed as follows:
<script type="text/javascript"> window.location.href="fbconnect:\/\/ success#_=_";
</script>
All other functionality (e..g when its not the first time) seems to work fine.
I suspect this is something to do with call backs not firing, but I've double checked all the delegate setting etc. All the facebook delegate methods are in the appDelegate and then referred to from the view controller.
Has anyone else had this issue? Any pointers would be warmly welcomed. I haven't posted any code yet as I'm not sure which bit to focus on and I've used all the standard code from the facebook developer site.
Many thanks,
Chris.
UPDATE
Thanks to #Kristofer Sommestad and #Senior for their help. I had a number of issues.
Don't Authorise Twice
The feed dialog request also requests an authorisation, so don't request them both at the same time.
Updated SDK
The SDK was updated after I found my issues - so keep checking.
What I hadn't realised was that the required code to use the SDK code had changed, specifically the code to call the feed dialog. Check out https://developers.facebook.com/docs/reference/dialogs/feed/.
What Logout Means
Logging out just logs the user out of your App, not out of facebook.

I also experienced the first issue, but solved it by making sure authentication wasn't triggered twice. Initially, I had done the following:
[_facebook authorize:permissions];
[_facebook dialog:#"feed" andParams:params andDelegate:self];
Not sure this is your problem, but I noticed that this messed things up as it actually triggered 2 authentication dialogs, where the second one ended up with the Javascript output you're also seeing.
For some reason I had figured that the second one wouldn't trigger a dialog if authorize already had done so....
Instead, I made sure to authorize: first, but not trigger the dialog:andParams:andDelegate until the authorization was completed with -fbDidLogin (and saving the dialog data to share as an instance variable).
Haven't seen any issues with still being able to post messages, but maybe it's related to the first issue somehow (?).
Hope this helps you out too.

Okay, I just did a pull from the GitHub repository, and I'm not getting this error anymore. It is, however, calling (void)dialog:(FBDialog*)dialog didFailWithError:(NSError *)error
Try updating to the latest version of the SDK and trying again.

This unwanted javascript-view bothers me too.
I just use the facebook feed dialog [facebook dialog: #"feed" andParams: myParameters andDelegate: ptrMyDialogDelegate];. Like shown at https://developers.facebook.com/docs/reference/dialogs/feed/. I do no other authorization anywhere else.
The Delegate is my AppModel-Class (not the AppDelegate). All methods of the FBDialogDelegate-Protocol are called correctly but after I close this annoying view.
I didn't use GIT. I downloaded the ZIP-File and copied all source files *.[h|m] from src/ directory (including src/JSON/ subdir) and the FBDialog.bundle (23 files in total) into my existing project.
Does it make any difference if I download the ZIP-File or clone the Facebook iOS SDK GIT-Repository?
To integrate the Facebook classes into my existing MyApp-project (means MyApp class tree like shown in Xcode Project Navigator) I do have to copy (e.g. drag'n drop or Xcode "Ad Files ...") the Facebook classes the same way, don't I?

Related

Facebook Messenger bot - sharing in webview not starting

I am creating a bot for Messenger that uses webview with some custom content. The webview works just fine, also closing the webview using Messenger Extensions works well. Now I need to start customized sharing flow from this webview (https://developers.facebook.com/docs/messenger-platform/webview/sharing). I call the method MessengerExtensions.beginShareFlow but nothing happens. Neither of success nor error are triggered. I understand that success would be fired after the sharing is complete, but I can't even start it, as the sharing UI does not appear at all.
I have double-checked all points listed here:
https://developers.facebook.com/docs/messenger-platform/webview/troubleshooting
What can be wrong? My bot is still not submitted for review (for obvious reasons - it is not finished yet and is missing some functionality) - is that be the problem? I would be happy to contact FB developers support directly, but I can't find a place to do it (btw: this is just hilarious).
In my case the problem was that I was not specifying ImageURL. The call to beginShareFlow just crashed in such case (error handler was not called).

iOS Google Plus API - Sharing or Logging In without going to Safari

So far everything I've found on the subject, is a NO.
My app works fine when the user logs in and shares, but both actions require mobile safari, which is a less than ideal experience for the user, has anyone found a way to either share a post or log in to Google + using a UIWebView or GET/POST?.
Any help will be greatly appreciated.
Thanks.
Easiest answer is no, as you say. The SDK will actually try to fall back through the following:
Log in via Google+ app (this is the nice result, but requires having the Google+ app installed)
Log in via Chrome
Log in via Mobile Safari
You can control the first part with the attemptSSO flag on the GPPSignIn object - if you set that to NO it wont try to use the Google+ app. You'll generally want it to try the Google+ app first. Sharing always happens via the web (chrome/safari) with the current API version (1.2.1) though.
You can SignIn via Google+ into UIWebView.
GTMOAuth2ViewControllerTouch *_googlePlusCtrl = [[GTMOAuth2ViewControllerTouch alloc]
initWithScope:#"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me"
clientID:GOOGLE_PLUS_CLIENT_ID
clientSecret:GOOGLE_PLUS_CLIENT_SECRET
keychainItemName:#"GooglePlus_Sample_App"
delegate:self
finishedSelector:#selector(viewController:finishedWithAuth:error:)];
Hope this will help you.
Well that's the thing. It's possible. First step - download sample project from here - https://github.com/emysa341/Login-with-gmail-google-g--using-oath-2.0-protocol. Second step, in the response- connection did finish loading, make another request - https://www.googleapis.com/oauth2/v1/userinfo?access_token=%# . Use the access token you got from the 1st request. Now in the response, you will get the user data. Also if you need the user's email, change the scope to "https://www.googleapis.com/auth/userinfo.email".

Facebook login social plugin stopped working

Last week suddenly the XFBML login button stopped working on our site. Instead of showing a nice FB login button, it just shows the button text. In Firebug, I'm getting an error:
TypeError: k.root is null
Strangely, the problem occurs on our production environment, test environment and my own development environment. The production environment hasn't been updated or changed for quite some time so it's not code changes on our end. All three environments also connect to separate Facebook apps, each with a different appID, so it also can't be a (accidental) configuration error with the Facebook app.
Does anyone know if it's perhaps possible that this is an issue on Facebook's end? They did do a compatibility breaking update on 5th of September, but as far as I can see, the changes are not related to the login button.
Anyone know what could possibly cause this?
This was a bug that would occur if you called FB.init prior to document.body being defined, (as in the HEAD), this has now been resolved.
I started to face this issue last week as well. I managed to solve with one of the options below:
1) The app's 'App Domains' was misconfigured (it should be a domain name and not a full URL):
Source: https://developers.facebook.com/bugs/225729134220754
or
2) Just replace the div (containing class fb-login-button) with a regular button to call FB.login, and all the things will start to work again.

Stopped Working: FB.ui with method: 'feed' suddenly quit working

This question is similar to: Facebook Error 191 on canvas app using FB.ui() for the 'feed' dialog (worked before, stopped working last week) which was never answered.
Starting today, after the user likes the page and enters the contest, the share dialog which presented itself stopped working and gave:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
when logged in as an admin and just an error occurred for other users. This tab has been running well for a while now. I have confirmed it with an associate of mine. They did make a change to another part of the app (yesterday and today) but the sharing was still working until this afternoon. They did not change the part that generates the dialog.
The tab is: https://www.facebook.com/MedjoolDates/app_355398587864294
Anyone have any insight? Feel free to use 'cancel' rather than sharing and fake data to sign up, then unlike the page if you wish.
Thanks in advance.
David
Same problem here, there is a bug posted on Facebook Developes here:
https://developers.facebook.com/bugs/273845842724431
Can't help much without seeing your code.
One thing to check, make sure your redirection_uri is exactly as your domain registered with FB and that you include a trailing / ie http://www.myurl.com/ rather than http://www.myurl.com
I can't answer why it changed, but I had that error fixed by the above change before.
I am having the same issue. Am developing a new app with FB.ui feed functionality, which worked OK yesterday and today it gives the same error as OP.
Went back and checked an > 1 year old app with the same functionality; same error. I cannot see any other solution, than the FB dev team has changed something and not given notice.

Facebook FLogin button not working

I used to have the FLogin button for enabling users to login using Facebook.
Lately , I updated my website to become HTML 5 compliant and made some other changes.
The FLogin is not working since then.
I also updated the FLogin code using the latest code provided by Facebook.
Still the login process is not working.
Can anyone share with me the exact code for FLogin for HTML 5?
My websites are
Loud Letters - www.loudletters.com
Loud Review - www.loudreview.com
The FLogin related code is included in the end.
Regards
You’re trying to append a script element for the FB JS-SDK to the element #fb-root, but that doesn’t exists yet, because it comes only later in your HTML code. (Btw., why did you mess with the code for asynchronously loading the SDK in that way, instead of using the code like it’s shown in the docs?)
You should make some use of your browsers error console when developing javascript.