Send an invitation through the android application to facebook friends

How to send an invitation to my facebook friends through my Android app.

+3
source share
1 answer

Here's how you can do it:

public void inviteFriends(Activity activity, ArrayList<FriendInfo> friendsIds){
    // Safe programming
    if(friendsIds == null || friendsIds.size() == 0)        
        return;

    Bundle parameters = new Bundle();

    // Get the friend ids
    String friendsIdsInFormat = "";
    for(int i=0; i<friendsIds.size()-1; i++){
        friendsIdsInFormat = friendsIdsInFormat + friendsIds.get(i) + ", ";
    }
    friendsIdsInFormat = friendsIdsInFormat + friendsIds.get(friendsIds.size()-1).getId();

    parameters.putString("to", friendsIdsInFormat);
    parameters.putString( "message", "Use my app!");

    // Show dialog for invitation
    mFacebook.dialog(activity, "apprequests", parameters, new Facebook.DialogListener() {
        @Override
        public void onComplete(Bundle values) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onFacebookError(FacebookError e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onError(DialogError e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onCancel() {
            // TODO Auto-generated method stub

        }
    });

}

dialogue link

+6
source

Source: https://habr.com/ru/post/1796638/


All Articles