Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

share successcb does not return postId #12

Open
bjunix opened this issue May 7, 2014 · 3 comments
Open

share successcb does not return postId #12

bjunix opened this issue May 7, 2014 · 3 comments

Comments

@bjunix
Copy link

bjunix commented May 7, 2014

The share function does not return the post id on success:

I guess it is supposed to work like the feed function and https://github.com/ccsoft/cordova-facebook/blob/master/www/CordovaFacebook.js#L94 should look like:

if (successcb) {
    if (response && response.post_id) {
        successcb(response.post_id);
    } else {
        successcb(null);
    }
}

I patched this locally and can confirm that this will work on iOS. Will test android later.

Anyhow, thanks for the work on this plugin! Much appreciated...

@koraybalci
Copy link
Member

Hi there,

I remember this issue vaguely, so I might be wrong but I suppose there was an inconsistency between iOS and Android on that. If you can test it on Android and let me know, I can apply the patch both in typescript and javascript sides of the plugin.

@bjunix
Copy link
Author

bjunix commented May 8, 2014

Ok, I can confirm it works in Android, with native FB App installed and without.

But now I stumbled over the next problem. If I use the native iOS FB App the share function does not return the postID as well. I previously only tested without having the FB App installed.

After digging in the code, there is the same problem in the native iOS code. Feed works fine, but share does not return the postId to the javascript function.

I see that it is even documented this way, but the Facebook SDK supports it and it is quite easy to fix. Or is there any other reason why you do not support postId in native iOS?

com.ccsoft.plugin.CordovaFacebook/src/ios/CordovaFacebook.m:340 should look like this:

pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:results];

Now there is the problem, that facebook native SDK returns postId and not post_id. You could normalize this in the iOS code, but as I am not so fluent in Objective-C I fixed it in CordovaFacebook.js:

if (successcb) {
    if (response && response.post_id) {
        successcb(response.post_id);
    } else if (response && response.postId) {
        successcb(response.postId);
    } else {
        successcb(null);
    }
}

@ducnhdtn
Copy link

ducnhdtn commented Aug 16, 2017

Hi,
Try to use "scope: 'email,user_posts,publish_actions'" as below:

window.fbAsyncInit = function () {
    FB.init({
      appId  : '<?php echo $appId ?>',
      status : true,
      xfbml  : true,
      version: 'v2.10',
      cookie: true,
      oauth: true
    });
    FB.AppEvents.logPageView();
      }, { scope: 'email,user_posts,publish_actions' }); /* perms changed to scope */
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants