Skip to content
This repository has been archived by the owner on Aug 3, 2019. It is now read-only.

Send request

Roman Kushnarenko edited this page Oct 16, 2014 · 1 revision

Facebook supports three kind of dialogs for invite friends. One dialog shows all your friends and user can select who he/she wants to invite. In other dialog you set suggested friends only and the last one, you set concrete one friend.

For all options, set OnInviteListener:

OnInviteListener onInviteListener = new OnInviteListener() {
	@Override
	public void onComplete(List<String> invitedFriends, String requestId) {
		Log.i(TAG, "Invitation was sent to " + invitedFriends.size() + " users with request id " + requestId); 
	}
	
	@Override
	public void onCancel() {
		Log.i(TAG, "Canceled the dialog");
	}

	/* 
	 * You can override other methods here: 
	 * onFail(String reason), onException(Throwable throwable)
	 */
};

All

Show dialog with a list of all your friends. Call for invite(Activity, String, OnInviteListener) The String is the message to be shown in the invitation.

mSimpleFacebook.invite("I invite you to use this app", onInviteListener);

Suggested friends

Show dialog with a list of suggested friends. Set array of user ids.

String[] friends = new String[] {
	"630243197",
	"584419361",
	"1456233371",
	"100000490891462"
};
mSimpleFacebook.invite(friends, "I invite you to use this app", onInviteListener);

One friend only

Show dialog with only one friend to invite.

String friend = "630243197";
mSimpleFacebook.invite(friend, "I invite you to use this app", onInviteListener);
Clone this wiki locally