+ * Copyright 2015-2016 GetSocial B.V.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+using System.Collections.Generic;
+using GetSocialSdk.Core;
+public class FacebookInvitePlugin : IInvitePlugin
+ #region IInvitePlugin implementation
+ public bool IsAvailableForDevice()
+ public void InviteFriends(string subject, string text, string referralDataUrl, byte[] image,
+ Action<string, List<string>> completeCallback,
+ Action<Exception> errorCallback)
+ SendInvite(referralDataUrl, completeCallback, cancelCallback, errorCallback);
+ // NOTE: Due to a bug with the facebook plugin for Unity4x for the Android platform we need to:
+ // 2) log in to Facebook
+ // close the Smart Invites window
+ GetSocial.Instance.CloseView(true);
+ // Your required permissions
+ var requiredPermissions = new []
+ FB.LogInWithReadPermissions(requiredPermissions, result =>
+ // reopen the Smart Invites window
+ GetSocial.Instance.RestoreView();
+ SendInvite(referralDataUrl, completeCallback, cancelCallback, errorCallback);
+ // The auth failed or the user cancelled the login
+ private void SendInvite(string referralDataUrl,
+ Action<string, List<string>> completeCallback,
+ Action<Exception> errorCallback)
+ FB.Mobile.AppInvite(new Uri(referralDataUrl), null,
+ if(!string.IsNullOrEmpty(result.Error))
+ var errorMsg = "Failed sending app invite: " + result.Error;
+ Debug.LogError(errorMsg);
+ errorCallback(new Exception(errorMsg));
+ completeCallback(null, null);