Has anyone had success using Xamarin.Facebook AppInviteDialog?

I am using the latest NuGet package "Facebook SDK for Xamarin" Version 4.0.1.0.

So far I manage to bring up a Facebook app invite dialog, select a friend, and then send the invite on its way. It appears to be working however the invite is never received by any of my Facebook friends. I have also noticed that I never get a result from the callbacks which makes me think something wrong.

Any thoughts?

Thank You

    const String APP_LINK_URL = @"https://fb.me/XXXXXXXXXXXX"; // Hiding actual values from public.
    const String PREVIEW_IMAGE_URL = @"http://My.Website.com/images/FeatureGraphic1200x628.jpg"; // Hiding actual values from public.

    ICallbackManager _callBackManager;
    CCallback _callBack;
    AppInviteDialog _appInviteDialog;

    public Boolean DoAppInvite(Activity Activity) {
        try {
            if (!_bIsInitialized)
                Initialize(Activity);

            if (!_bIsCanShow)
                return false;

            _callBackManager = CallbackManagerFactory.Create();

            AppInviteContent aic = (AppInviteContent)new AppInviteContent.Builder()
                .SetApplinkUrl(APP_LINK_URL)
                .SetPreviewImageUrl(PREVIEW_IMAGE_URL)
                .Build();

            _appInviteDialog = new AppInviteDialog(Activity);
            _callBack = new CCallback();
            _appInviteDialog.RegisterCallback(_callBackManager, _callBack);
            _appInviteDialog.Show(aic);

            return true;
        } catch (Exception ex) {
            CCommon.LogError("DoAppInvite Exception", ex);
            return false;
        }
    }

} // class...

public class CCallback : Java.Lang.Object, IFacebookCallback {
    public void OnCancel() {
        CCommon.LogWarn("CFacebookAppInvites: Canceled.");
    }

    public void OnError(FacebookException error) {
        CCommon.LogError("CFacebookAppInvites: Exception: " + error.Message);
    }

    public void OnSuccess(Java.Lang.Object result) {
        CCommon.LogInfo("CFacebookAppInvites Success");
    }
} // class...
Tagged:

Answers

  • BradCrandallBradCrandall USMember ✭✭

    I spent more time on this problem and created a new application from scratch to help simplify the problem. The code below works. I am now able to get a SUCCESS response from the Facebook SDK, however, none of my Facebook friends ever get the invite, like it is never sent. I now believe the issue resides in Facebook.

    Does anyone know why Facebook would reply with a SUCCESS response and not actually send the invite to Friends? Could it be that the application being referenced in the invite is not actually in production (at Google Play) but only in beta? Does Facebook app invite only support Canvas apps and not Android or iOS apps?

    Any comments or suggestions is welcome.
    Thank you.

    using System;
    using Android.App;
    using Android.Content;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.OS;
    
    using Xamarin.Facebook;
    using Xamarin.Facebook.Share.Widget;
    using Xamarin.Facebook.Share.Model;
    
    namespace FacebookAppInviteTest {
        [Activity(Label = "FacebookAppInviteTest", MainLauncher = true, Icon = "@drawable/icon")]
        public class MainActivity : Activity {
            const String APP_LINK_URL = @"https://fb.me/999999999999999"; // Not actual  value.
            const String PREVIEW_IMAGE_URL = @"http://xxx.xxxxxx.com/images/FeatureGraphic1200x628.jpg"; // Not actual  value.
    
            const String TAG = "FacebookAppInvite Test";
    
            int count = 1;
    
            ICallbackManager _callbackManager;
            Boolean _bIsCanShow;
    
            protected override void OnCreate(Bundle bundle) {
                base.OnCreate(bundle);
    
                // Set our view from the "main" layout resource
                SetContentView(Resource.Layout.Main);
    
                FacebookSdk.SdkInitialize(ApplicationContext);
                _bIsCanShow = AppInviteDialog.CanShow();
                _callbackManager = CallbackManagerFactory.Create();
    
                Button btn = FindViewById<Button>(Resource.Id.MyButton);
                btn.Click += delegate {
                    btn.Text = string.Format("{0} clicks!", count++);
    
                    if (_bIsCanShow)
                        doAppInvite();
                    else
                        Android.Util.Log.Info(TAG, "Facebook is unavailable");
                };
            }
    
            protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) {
                base.OnActivityResult(requestCode, resultCode, data);
    
                _callbackManager.OnActivityResult(requestCode, (int)resultCode, data);
            }
    
            void doAppInvite() {
                var aic = (AppInviteContent)new AppInviteContent.Builder()
                    .SetApplinkUrl(APP_LINK_URL)
                    .SetPreviewImageUrl(PREVIEW_IMAGE_URL)
                    .Build();
    
                var appInviteDlg = new AppInviteDialog(this);
                appInviteDlg.RegisterCallback(_callbackManager, new CCallback());
                appInviteDlg.Show(aic);
            }
    
            public class CCallback : Java.Lang.Object, IFacebookCallback {
                public void OnCancel() {
                    Android.Util.Log.Warn(TAG,"Canceled");
                }
    
                public void OnError(FacebookException error) {
                    Android.Util.Log.Error(TAG, error.Message);
                }
    
                public void OnSuccess(Java.Lang.Object result) {
                    Android.Util.Log.Info(TAG, "Success");
                }
            }
        } // class...
    } // namespace...
    
  • BradCrandallBradCrandall USMember ✭✭

    I have since learned that AppInviteDialog is not broken. It seems that app invites will only be received under the following conditions:

    1. Facebook friend must have an android device for my app to install on..
    2. Facebook friend doesn't already have my android application installed.
    3. Facebook friend is not blocking app invites from his/her Facebook page.
    4. Facebook App Invites expire after a unspecified time period (I think days).

    It seems all my Facebook friends either did not have an android device (e.g. they have iPhones) or already had the application installed. This is why they never received the app invites I have been sending.

  • AMAXAMAX USMember ✭✭

    Have you solve this issue?

Sign In or Register to comment.