Invite Friends using Facebook Lite app Android - android

I have implemented the Facebook invite friend in my app. It is working fine when I have installed the Facebook Application in my device. But if I uninstall the Facebook app and Download the Facebook lite application then it is not working.
Here is my code snippet.
Please help me.
Thanks in advance.
public void openDialogInvite(final Activity activity) {
String AppURl = "**************"; //Generated from //fb developers
CallbackManager sCallbackManager = CallbackManager.Factory.create();
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(AppURl)
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
appInviteDialog.registerCallback(sCallbackManager,
new FacebookCallback<AppInviteDialog.Result>() {
#Override
public void onSuccess(AppInviteDialog.Result result) {
Log.d("Invitation", "Invitation Sent Successfully");
System.out.println("test onSuccess");
}
#Override
public void onCancel() {
System.out.println("test on cancel");
}
#Override
public void onError(FacebookException e) {
Log.d("Invitation", "Error Occured");
System.out.println("test Error" + e.getMessage());
}
});
appInviteDialog.show(content);
}
}

Related

How to Check Facebook invite app to friends is successfully sent invitation or not sent in android [duplicate]

In the new Fb SDK 4.0 for Android you can register a callback for the LoginButton according to the docs. https://developers.facebook.com/docs/facebook-login/android/v2.3
The question is is this possible for the AppInviteDialog as well? Or is there any other way to identify if the App-Invite was successful or not?
Yes, this is possible.
public static void openDialogInvite(final Activity activity)
{
String appLinkUrl, previewImageUrl;
appLinkUrl = "your app link url";
previewImageUrl = "https://www.example.com/my_invite_image.jpg";
if (AppInviteDialog.canShow())
{
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
CallbackManager sCallbackManager = CallbackManager.Factory.create();
appInviteDialog.registerCallback(sCallbackManager, new FacebookCallback<AppInviteDialog.Result>()
{
#Override
public void onSuccess(AppInviteDialog.Result result)
{
}
#Override
public void onCancel()
{
}
#Override
public void onError(FacebookException e)
{
}
});
appInviteDialog.show(content);
}
}

push notification not showing

I am implementing invite friends from my app using facebook.All the things working fine but when I am inviting friend then push notification not showing in my friend notification.but notification send by app successfully.
How to solve this problem.
public class Trail extends Activity {
private CallbackManager sCallbackManager;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_trail);
openDialogInvite(this);
}
public void openDialogInvite(final Activity activity) {
String AppURl = "https://fb.me/Id number...."; //Generated from //fb developers
String previewImageUrl = "";
sCallbackManager = CallbackManager.Factory.create();
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(AppURl).setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
appInviteDialog.registerCallback(sCallbackManager,
new FacebookCallback<AppInviteDialog.Result>() {
#Override
public void onSuccess(AppInviteDialog.Result result) {
Log.d("Invitation", "Invitation Sent Successfully");
finish();
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException e) {
Log.d("Invitation", "Error Occured");
}
});
appInviteDialog.show(content);
}
}
}

No image and content in preview when sharing Facebook app link for mobile only content

When I try to implement the sharing of links for the app links using the ShareDialog using ShareLinkContent, the image and title are not shown correctly when the actually the post is shared.
String url = "https://fb.me/" + id; //Id is generated by app links hosting api
ShareDialog shareDialog = new ShareDialog(activity);
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent.Builder linkContentBuilder = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(url))
.setContentTitle(contentTitle)
.setContentDescription(contentDescription);
if (imageUrl != null) {
linkContentBuilder.setImageUrl(Uri.parse(imageUrl));
}
ShareLinkContent linkContent = linkContentBuilder.build();
shareDialog.setShouldFailOnDataError(true);
shareDialog.registerCallback(activity.callbackManager,
new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
Log.d(TAG, "Facebook sharing successful");
}
#Override
public void onCancel() {
Log.d(TAG, "Facebook sharing cancelled");
}
#Override
public void onError(FacebookException e) {
Log.d(TAG, "Facebook sharing error");
Log.d(TAG, e.getMessage());
}
});
shareDialog.show(linkContent);
}
But the sharing looks like below:
Facebook sharing
Can someone help me out?

AppInviteDialog android in hindi in most of devices

I want to send my app invites from Facebook.The code I've written is able to send invites but I'm facing two problems.
I don't receive any callback after invitation.
In most of devices Invite dialog has default language Hindi(Click for Screenshot). How can I change the defaults to English?.
PS: I have checked default language in my Facebook developer account app is English.
Any help would be appreciated.
String AppURl = "<My Facebook App URL>";
String previewImageUrl = "<Preview Image URL>";
sCallbackManager = CallbackManager.Factory.create();
AppInviteDialog appInviteDialog = new AppInviteDialog(getActivity());
appInviteDialog.registerCallback(sCallbackManager,
new FacebookCallback<AppInviteDialog.Result>() {
#Override
public void onSuccess(AppInviteDialog.Result result) {
Log.d("Invitation", "Invitation Sent Successfully");
Toast.makeText(getActivity(), "Invitation Sent Successfully", Toast.LENGTH_SHORT).show();
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException e) {
Log.d("Invitation", "Error Occured");
}
});
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(AppURl)
.setPreviewImageUrl(previewImageUrl)
.build();
appInviteDialog.show(content);
}

Using facebook sdk 4.4.1. Want to get the number of invites sent by the app user using app invite dialog?

i want to calculate the number of person app user has invited from his friend list.
this is my code. in result i m getting null.
public void openDialogInvite(final Activity activity) {
String AppURl = "https://fb.me/659724450828700"; //Generated from //fb developers
//String previewImageUrl = " ";
sCallbackManager = CallbackManager.Factory.create();
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(AppURl)
//.setPreviewImageUrl(previewImageUrl)
.build();
final AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
appInviteDialog.registerCallback(sCallbackManager,
new FacebookCallback<AppInviteDialog.Result>() {
#Override
public void onSuccess(AppInviteDialog.Result result) {
Log.v("invitation", result.toString());
// setting parameters for request execution for both graph api request
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException e) {
Log.d("Invitation", "Error Occured");
}
});
appInviteDialog.show(content);
}
thanks in advance.
It is is not possible, to get the list of invited friends of a user until unless ur app is not a game on canvas.

Categories

Resources