简体   繁体   中英

Facebook FB.ui send method not working on mobile web and need alternative

I am trying to allow users of my app to notify multiple Facebook friends that they need them to vote for their favorite item on a web page. I have been using the FB send method ( https://developers.facebook.com/docs/reference/dialogs/send/ ) and it has been working fine on desktop ( code is below ) but I just realized that I overlooked where it says in the docs that this dialog is "not supported on mobile devices."

Are there any alternatives to the send method that would allow a user to send a private message to their friends from mobile browsers? Perhaps a way to trick the api into thinking it's desktop?

I'm also open to using another FB dialog so long as it: 1) is functional from mobile browsers 2) allows pre-populating of recipients and 3) is private between the sender and the recipient such as a private message or notification.

Any ideas would be much appreciated. Thanks

Code for FB send method:

function resetSelector(){
 $('#fs-user-list').empty();

 $(".mutual-friends-link").fSelector({

max: 5,
excludeIds: exclusions,
facebookInvite: false,
lang: {
  title: "Pick your mutual friends who will vote on the gifts (Last step)",
  buttonSubmit: "Add Accomplices",
  selectedLimitResult: "Limit is {5} people."
},
closeOnSubmit: true,
onSubmit: function(response){
  var accompliceUid;
  accomplices = response;
  $('#index-accomplices').empty()
  var i = 0

  var FB_notification = function(accomplice, poll_id){
    FB.api('https://graph.facebook.com/', 'post', {
        id: "http://giftadvisor.herokuapp.com/polls/" + poll_id,
        scrape: true
      }, function(response){
        FB.ui({
        method: 'send',
        to: [accomplice],
        link: "http://giftadvisor.herokuapp.com/polls/" + poll_id,  
        }, fbCallback)
      })
    }

  var fbCallback = function(){
    console.log(i++)
    if (i === accomplices.length){
      window.location = "/polls/" + poll.id
    }
  }
    _.each(accomplices, function(accomplice){
      $('#index-accomplices').append('<img class="accomplices" src="http://graph.facebook.com/' + accomplice + '/picture?type=large">');

      user = new User({uid: accomplice});
      user.save(null,
        {success: function(response){
          console.log("users saved")
          console.log(response.attributes.uid);
          vote = new Vote();
          vote.save({
            user_id: response.attributes.id, 
            poll_id: poll.id, 
            image_url: "http://graph.facebook.com/" + response.attributes.uid + "/picture"
            },{success: function(response){
              FB_notification(accomplice, poll.id);
            } 
         }
        );
        }});
    });
  // }});

},
onClose: function(){

  // FB_notification(accomplices, poll.id);
}

}); }

The only thing I've seen approximating this is to use the now-deprecated Chat API. See, for example, what Grouper does .

Send dialog is really what I want, but failure on mobile web makes it useless. Have you found any other approaches that may work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM