Wizcorp / phonegap-facebook-plugin

The official plugin for Facebook in Apache Cordova/PhoneGap
Other
1.9k stars 2.01k forks source link

Plugin only works when native FB app is not installed (Android) #263

Closed jensCocquyt closed 9 years ago

jensCocquyt commented 11 years ago

I've followed all the steps in the Android 'getting started' and everything works fine when I run the app on a device (emulator and real) that doesn't have the official Facebook app installed. When i run it on a device which has the official Facebook app installed and I click on the login button, the Facebook dialog appears and it asks for permission. I choose OK, the dialog disappears and nothing happens. No error or other alert appears and i'm not logged in neither.

Any ideas?

The javascript

    function logout() {
        FB.logout(function(response) {
                  alert('logged out');
                  });
    }

    function logIn() {

         try {
              FB.init({ appId: "*****************", nativeInterface: CDV.FB, useCachedDialogs: false });

              } catch (e) 
              {
              alert("error");
              }

        FB.login(
                 function(response) {
                 if (response.authResponse) { 

                  // not invoked
                  alert('logged in');      

                 } else {
                  // not invoked
                 alert('error');
                 }
                 },
                 { scope: "email" }
                 );
richardortiz84 commented 11 years ago

This usually means that your key hash is not correct in your facebook developer console.

sebastianzillessen commented 11 years ago

Hello. I have the same issues here. Working on Android 4.2.2. My key hash is definitely correct, i checked it twice and even exported the application with my production keys to check it again. Still not working.

It worked a week ago and I did not do any changes. Could it be, that facebook changed its API?

I have some deadlines. So it would be great if someone has some fixes for me... Thanks!

EDIT:

I got it working again. I used the "offline_access" token as scope. That was the reason why it failed. Sorry.

richardortiz84 commented 11 years ago

How long has it been since you added your new hashes to the facebook developer console? It can sometimes take 12 hours to update. Did you change machines for development? On Apr 16, 2013 5:10 AM, "Spitzeljagd OÜ" notifications@github.com wrote:

Hello. I have the same issues here. Working on Android 4.2.2. My key hash is definitely correct, i checked it twice and even exported the application with my production keys to check it again. Still not working.

It worked a week ago and I did not do any changes. Could it be, that facebook changed its API?

I have some deadlines. So it would be great if someone has some fixes for me... Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/phonegap/phonegap-facebook-plugin/issues/263#issuecomment-16434172 .

sebastianzillessen commented 11 years ago

I figured it out, what the problem was. I added publish_actions as scope. This caused the failure, because I had not setted cached to true. Therefore there was no error message. Right now I detected, that you cannot perform read and write permissions in one call. That was my mistake. I removed it and all works well.

Thanks for your help.

jl-digital commented 11 years ago

Do you have a solution for getting read and write permissions (maybe in separate calls)?

Spielarchitekten commented 11 years ago

No. Unfortunately not right now. But this is planned in the next sprint. So I hope I can post a solution in about 4 weeks.... On 17 Apr 2013 11:32, "Joan" notifications@github.com wrote:

Do you have a solution for getting read and write permissions (maybe in separate calls)?

— Reply to this email directly or view it on GitHubhttps://github.com/phonegap/phonegap-facebook-plugin/issues/263#issuecomment-16493306 .

richardortiz84 commented 11 years ago

I think fixing silent fails would be very helpful. It used to be you could use an alert on the FB responses and see the problem, such as an invalid hash, now it just never responds. On Apr 17, 2013 7:24 AM, "Spitzeljagd OÜ" notifications@github.com wrote:

No. Unfortunately not right now. But this is planned in the next sprint. So I hope I can post a solution in about 4 weeks.... On 17 Apr 2013 11:32, "Joan" notifications@github.com wrote:

Do you have a solution for getting read and write permissions (maybe in separate calls)?

— Reply to this email directly or view it on GitHub< https://github.com/phonegap/phonegap-facebook-plugin/issues/263#issuecomment-16493306>

.

— Reply to this email directly or view it on GitHubhttps://github.com/phonegap/phonegap-facebook-plugin/issues/263#issuecomment-16500174 .

stevengill commented 11 years ago

You should be able to do read and write permissions as separate calls with this plugin. Doing them in one call will fail.

I believe the scrumptious example shows this in action. https://github.com/phonegap/phonegap-facebook-plugin/blob/master/example/Scrumptious/www/js/main.js#L239-L252

As far as I know, this should be working for Android. If it isn't, let me know.

Spielarchitekten commented 10 years ago

Thanks that works!

ThamizharasaN2116 commented 9 years ago

How to get extended permission (publish_actions) to publish photos in user wall. I'm unable to get this permission during login. Please help me to resolve this issue to publish photos in user wall using phonegap-facebook-plugin...!

sebastianzillessen commented 9 years ago

You cannot do this on the Login. You have to do two queries for that.

You should be able to do read and write permissions as separate calls with this plugin.

Hope this helps.

ThamizharasaN2116 commented 9 years ago

Hi @sebastianzillessen I tried to make an facebookConnectPlugin.api method in login success function. but it didn't worked. Please suggest me any code to work with that...!

sebastianzillessen commented 9 years ago

Please share your code here or in a jsfiddle, otherwise it is really hard to help....

ThamizharasaN2116 commented 9 years ago

@sebastianzillessen thank you for your reply.

var fbLoginSuccess = function (userData) {
                alert("UserInfo: " + JSON.stringify(userData));
                alert("UserInfo: " + JSON.stringify(userData));
facebookConnectPlugin.login(["publish_actions"],
                        function(response){alert("Data"+JSON.stringify(response))},
                        function (error) { alert("" + error) }
                    );
}

facebookConnectPlugin.login(["user_friends"],
                fbLoginSuccess,
                function (error) { alert("" + error) }
            );

@sebastianzillessen actually I tried the above code but it's not getting the token for publish_actions. Instead of that i tried the below code inside the login success call to directly post an image. But it also not working. What should I do to resolve the problem. Please kindly help me to resolve this issue...!

var imgURL = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/t1.0-1/c8.0.50.50/p50x50/1901419_674998005877334_1216071826_n.jpg";

facebookConnectPlugin.api('/USER_ID/photos', 'post', {
                    message:'photo description',
                    url:imgURL        
                }, function(response){
                    if (!response || response.error) {
                        alert('Error occured'+JSON.stringify(response));
                    } else {
                        alert('Post ID: ' + response.id + JSON.stringify(response));
                    }
                });
sebastianzillessen commented 9 years ago

So what is your output then with the first approach?

The api call is as well wrong. check out the documentation:

 facebookConnectPlugin.api(String requestPath, Array permissions, Func success, Func failure)
ThamizharasaN2116 commented 9 years ago

@sebastianzillessen for the first approach it's showing that already authroized the app. I checked the app permissions in my facebook account but there is not permission given for the app to post behalf me. I stuck on this issue for more than 5 days. Still i cant find solution to post photos in facebook wall by the user. Kindly help me to solve this issue...!

sebastianzillessen commented 9 years ago

SO but have you tried it with the correct permissions? And I think you should open a new issue for that, because it is not at all related to Plugin only works when native FB app is not installed

ThamizharasaN2116 commented 9 years ago

Yeah i opened it but no response. While following the thread i just triggered the question here. Sorry to post the question here...!

https://github.com/phonegap/phonegap-facebook-plugin/issues/528

rrusher commented 9 years ago

I've been fighting this for a couple of days. Everything works when the FB native app is not installed. But when the native app is installed, it starts to authenticate and then I get nothing.

In my controller, I have a function that tries the plugin's login():

appSettings.enableFB = function () {
  var fbLoginSuccess = function (userData) {
    alert("Settings fbLoginSuccess: " + JSON.stringify(userData));
  }
  var fbLoginFail = function (error) { 
    alert(error);
  }
  facebookConnectPlugin.login([], fbLoginSuccess, fbLoginFail);
};

I've tried setting the permissions individually to: public_profile, publish_actions and offline_access But none of them have worked. So I have it empty, as you can see in the code above.

Again, this works when the native FB app is not installed. I'm building with my Android debug key. I've added my debug key hash to the Facebook App on developers.facebook.com.

I get this far. 20140716_173817_928

Then it does this and then returns back to my app without being logged in. 20140716_173840_762

What am I missing?

aogilvie commented 9 years ago

@rrusher Sounds like your nearly there! Without being condescending, have you tried signing out of the native app and making sure to login to the native app with your FB developer tester account? A real FB user won't work until your FB app goes live.

rrusher commented 9 years ago

No worries @aogilvie. I'm open to any ideas. I am using the correct FB test account. I did go through the FB app to make sure I have all of the information they want filled in and submitted for review. It says it's live, but my app still doesn't authenticate.

rrusher commented 9 years ago

I'm getting a permissions error when I try to post. I'm not sure why. Keys match. fb_app_id and fb_app_name are correct.

It works on iOS. Not Android. Very frustrating.

aogilvie commented 9 years ago

I used the sample app included in platforms/android and the following login code:

facebookConnectPlugin.login( ["public_profile"], 
                    function (response) { alert(JSON.stringify(response)) },
                    function (response) { alert(JSON.stringify(response)) });

I also added my hash to the settings for Android:

screen shot 2014-07-22 at 1 46 26 pm

Then I was able to login via the native FB app. I can also successfully post using:

var showDialog = function () { 
                facebookConnectPlugin.showDialog( { method: "feed" }, 
                    function (response) { alert(JSON.stringify(response)) },
                    function (response) { alert(JSON.stringify(response)) });
            }

Can you post a full log from adb logcat?

rrusher commented 9 years ago

I was able to finally figure this out. Working on both platforms, with/without the Facebook app being installed. https://play.google.com/store/apps/details?id=com.on3software.courageClassic

I had placed my hash key on the FB app site. But for some reason, FB was looking for a different key. So I went through all of my keys and put them all on the FB app. Still didn’t work.

So I updated the Java to output the key it was looking for and then added it to the FB app. That worked. I still have no idea where this hash key came from. I went through all of my keys, none of which match the key they were looking for. Ugh FB!

Ionic + AngularJS + Cordova + Facebook Connect Plugin + Angular Leaflet Directive It could be a bit faster, but not bad.

aogilvie commented 9 years ago

Closing. Out-of-date.

ngethe commented 9 years ago

@rrusher What do you mean by Updated Java I an having issues and I suspect it Hash Key related the App only work when there are no Native App installed.

mailtoamirjohn commented 7 years ago

I am getting the same issues,

I don't know what I missed, please check following link for more details

http://stackoverflow.com/q/40087845/3600674