repo_name
stringlengths
1
52
repo_creator
stringclasses
6 values
programming_language
stringclasses
4 values
code
stringlengths
0
9.68M
num_lines
int64
1
234k
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using System.Linq; /// <summary> /// Contains the access token and related information. /// </summary> public class AccessToken { /// <summary> /// Initializes a new instance of the <see cref="AccessToken"/> class. /// </summary> /// <param name="tokenString">Token string of the token.</param> /// <param name="userId">User identifier of the token.</param> /// <param name="expirationTime">Expiration time of the token.</param> /// <param name="permissions">Permissions of the token.</param> /// <param name="lastRefresh">Last Refresh time of token.</param> internal AccessToken( string tokenString, string userId, DateTime expirationTime, IEnumerable<string> permissions, DateTime? lastRefresh, string graphDomain) { if (string.IsNullOrEmpty(tokenString)) { throw new ArgumentNullException("tokenString"); } if (string.IsNullOrEmpty(userId)) { throw new ArgumentNullException("userId"); } if (expirationTime == DateTime.MinValue) { throw new ArgumentException("Expiration time is unassigned"); } if (permissions == null) { throw new ArgumentNullException("permissions"); } this.TokenString = tokenString; this.ExpirationTime = expirationTime; this.Permissions = permissions; this.UserId = userId; this.LastRefresh = lastRefresh; this.GraphDomain = graphDomain; } /// <summary> /// Gets the current access token. /// </summary> /// <value>The current access token.</value> public static AccessToken CurrentAccessToken { get; internal set; } /// <summary> /// Gets the token string. /// </summary> /// <value>The token string.</value> public string TokenString { get; private set; } /// <summary> /// Gets the expiration time. /// </summary> /// <value>The expiration time.</value> public DateTime ExpirationTime { get; private set; } /// <summary> /// Gets the list of permissions. /// </summary> /// <value>The permissions.</value> public IEnumerable<string> Permissions { get; private set; } /// <summary> /// Gets the user identifier. /// </summary> /// <value>The user identifier.</value> public string UserId { get; private set; } /// <summary> /// Gets the last refresh. /// </summary> /// <value>The last refresh.</value> public DateTime? LastRefresh { get; private set; } /// <summary> /// Gets the domain this access token is valid for. /// </summary> public String GraphDomain { get; private set; } /// <summary> /// Returns a <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.AccessToken"/>. /// </summary> /// <returns>A <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.AccessToken"/>.</returns> public override string ToString() { return Utilities.FormatToString( null, this.GetType().Name, new Dictionary<string, string>() { { "ExpirationTime", this.ExpirationTime.TotalSeconds().ToString() }, { "Permissions", this.Permissions.ToCommaSeparateList() }, { "UserId", this.UserId.ToStringNullOk() }, { "LastRefresh", this.LastRefresh.ToStringNullOk() }, { "GraphDomain", this.GraphDomain }, }); } internal string ToJson() { var dictionary = new Dictionary<string, string>(); dictionary[LoginResult.PermissionsKey] = string.Join(",", this.Permissions.ToArray()); dictionary[LoginResult.ExpirationTimestampKey] = this.ExpirationTime.TotalSeconds().ToString(); dictionary[LoginResult.AccessTokenKey] = this.TokenString; dictionary[LoginResult.UserIdKey] = this.UserId; if (this.LastRefresh != null) { dictionary[LoginResult.LastRefreshKey] = this.LastRefresh.Value.TotalSeconds().ToString(); } dictionary[LoginResult.GraphDomain] = this.GraphDomain; return MiniJSON.Json.Serialize(dictionary); } } }
155
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { /// <summary> /// Contains the names used for standard App Events. /// </summary> public static class AppEventName { /// <summary> /// App Event for achieved level. /// </summary> public const string AchievedLevel = "fb_mobile_level_achieved"; /// <summary> /// App Event for activated app. /// </summary> public const string ActivatedApp = "fb_mobile_activate_app"; /// <summary> /// App Event for added payment info. /// </summary> public const string AddedPaymentInfo = "fb_mobile_add_payment_info"; /// <summary> /// App Event for added to cart. /// </summary> public const string AddedToCart = "fb_mobile_add_to_cart"; /// <summary> /// App Event for added to wishlist. /// </summary> public const string AddedToWishlist = "fb_mobile_add_to_wishlist"; /// <summary> /// App Event for completed registration. /// </summary> public const string CompletedRegistration = "fb_mobile_complete_registration"; /// <summary> /// App Event for completed tutorial. /// </summary> public const string CompletedTutorial = "fb_mobile_tutorial_completion"; /// <summary> /// App Event for initiated checkout. /// </summary> public const string InitiatedCheckout = "fb_mobile_initiated_checkout"; /// <summary> /// App Event for purchased. /// </summary> public const string Purchased = "fb_mobile_purchase"; /// <summary> /// App Event for rated. /// </summary> public const string Rated = "fb_mobile_rate"; /// <summary> /// App Event for searched. /// </summary> public const string Searched = "fb_mobile_search"; /// <summary> /// App Event for spent credits. /// </summary> public const string SpentCredits = "fb_mobile_spent_credits"; /// <summary> /// App Event for unlocked achievement. /// </summary> public const string UnlockedAchievement = "fb_mobile_achievement_unlocked"; /// <summary> /// App Event for content of the viewed. /// </summary> public const string ViewedContent = "fb_mobile_content_view"; } }
99
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { /// <summary> /// Contains the parameter names used for standard App Events. /// </summary> public static class AppEventParameterName { /// <summary> /// App Event parameter for content ID. /// </summary> public const string ContentID = "fb_content_id"; /// <summary> /// App Event parameter for type of the content. /// </summary> public const string ContentType = "fb_content_type"; /// <summary> /// App Event parameter for currency. /// </summary> public const string Currency = "fb_currency"; /// <summary> /// App Event parameter for description. /// </summary> public const string Description = "fb_description"; /// <summary> /// App Event parameter for level. /// </summary> public const string Level = "fb_level"; /// <summary> /// App Event parameter for max rating value. /// </summary> public const string MaxRatingValue = "fb_max_rating_value"; /// <summary> /// App Event parameter for number items. /// </summary> public const string NumItems = "fb_num_items"; /// <summary> /// App Event parameter for payment info available. /// </summary> public const string PaymentInfoAvailable = "fb_payment_info_available"; /// <summary> /// App Event parameter for registration method. /// </summary> public const string RegistrationMethod = "fb_registration_method"; /// <summary> /// App Event parameter for search string. /// </summary> public const string SearchString = "fb_search_string"; /// <summary> /// App Event parameter for success. /// </summary> public const string Success = "fb_success"; } }
84
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; public class AuthenticationToken { /// <summary> /// Initializes a new instance of the <see cref="AuthenticationToken"/> class. /// </summary> /// <param name="tokenString">Token string of the token.</param> /// <param name="nonce">Nonce of the token.</param> internal AuthenticationToken( string tokenString, string nonce) { if (string.IsNullOrEmpty(tokenString)) { throw new ArgumentNullException("AuthTokenString"); } if (string.IsNullOrEmpty(nonce)) { throw new ArgumentNullException("AuthNonce"); } this.TokenString = tokenString; this.Nonce = nonce; } /// <summary> /// Gets the token string. /// </summary> /// <value>The token string.</value> public string TokenString { get; private set; } /// <summary> /// Gets the nonce string. /// </summary> /// <value>The nonce string.</value> public string Nonce { get; private set; } /// <summary> /// Returns a <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.AuthenticationToken"/>. /// </summary> /// <returns>A <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.AuthenticationToken"/>.</returns> public override string ToString() { return Utilities.FormatToString( null, this.GetType().Name, new Dictionary<string, string>() { { "TokenString", this.TokenString}, { "Nonce", this.Nonce }, }); } internal string ToJson() { var dictionary = new Dictionary<string, string>(); dictionary[LoginResult.AuthTokenString] = this.TokenString; dictionary[LoginResult.AuthNonce] = this.Nonce; return MiniJSON.Json.Serialize(dictionary); } } }
89
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; internal class CallbackManager { private IDictionary<string, object> facebookDelegates = new Dictionary<string, object>(); private int nextAsyncId; public string AddFacebookDelegate<T>(FacebookDelegate<T> callback) where T : IResult { if (callback == null) { return null; } this.nextAsyncId++; this.facebookDelegates.Add(this.nextAsyncId.ToString(), callback); return this.nextAsyncId.ToString(); } public void OnFacebookResponse(IInternalResult result) { if (result == null || result.CallbackId == null) { return; } object callback; if (this.facebookDelegates.TryGetValue(result.CallbackId, out callback)) { CallCallback(callback, result); this.facebookDelegates.Remove(result.CallbackId); } } // Since unity mono doesn't support covariance and contravariance use this hack private static void CallCallback(object callback, IResult result) { if (callback == null || result == null) { return; } if (CallbackManager.TryCallCallback<IAppRequestResult>(callback, result) || CallbackManager.TryCallCallback<IShareResult>(callback, result) || CallbackManager.TryCallCallback<IGamingServicesFriendFinderResult>(callback, result) || CallbackManager.TryCallCallback<IIAPReadyResult>(callback, result) || CallbackManager.TryCallCallback<ICatalogResult>(callback, result) || CallbackManager.TryCallCallback<IPurchasesResult>(callback, result) || CallbackManager.TryCallCallback<IPurchaseResult>(callback, result) || CallbackManager.TryCallCallback<IConsumePurchaseResult>(callback, result) || CallbackManager.TryCallCallback<ISubscribableCatalogResult>(callback, result) || CallbackManager.TryCallCallback<ISubscriptionsResult>(callback, result) || CallbackManager.TryCallCallback<ISubscriptionResult>(callback, result) || CallbackManager.TryCallCallback<ICancelSubscriptionResult>(callback, result) || CallbackManager.TryCallCallback<IInitCloudGameResult>(callback, result) || CallbackManager.TryCallCallback<IGameLoadCompleteResult>(callback, result) || CallbackManager.TryCallCallback<IScheduleAppToUserNotificationResult>(callback, result) || CallbackManager.TryCallCallback<IInterstitialAdResult>(callback, result) || CallbackManager.TryCallCallback<IRewardedVideoResult>(callback, result) || CallbackManager.TryCallCallback<IPayloadResult>(callback, result) || CallbackManager.TryCallCallback<ISessionScoreResult>(callback, result) || CallbackManager.TryCallCallback<ITournamentResult>(callback, result) || CallbackManager.TryCallCallback<ITournamentScoreResult>(callback, result) || CallbackManager.TryCallCallback<IGetTournamentsResult>(callback, result) || CallbackManager.TryCallCallback<IGroupCreateResult>(callback, result) || CallbackManager.TryCallCallback<IGroupJoinResult>(callback, result) || CallbackManager.TryCallCallback<IMediaUploadResult>(callback, result) || CallbackManager.TryCallCallback<ICreateGamingContextResult>(callback, result) || CallbackManager.TryCallCallback<ISwitchGamingContextResult>(callback, result) || CallbackManager.TryCallCallback<IChooseGamingContextResult>(callback, result) || CallbackManager.TryCallCallback<IGetCurrentGamingContextResult>(callback, result) || CallbackManager.TryCallCallback<IPayResult>(callback, result) || CallbackManager.TryCallCallback<IAppLinkResult>(callback, result) || CallbackManager.TryCallCallback<ILoginResult>(callback, result) || CallbackManager.TryCallCallback<IAccessTokenRefreshResult>(callback, result) || CallbackManager.TryCallCallback<IHasLicenseResult>(callback, result) || CallbackManager.TryCallCallback<ILoginStatusResult>(callback, result) || CallbackManager.TryCallCallback<IProfileResult>(callback, result) || CallbackManager.TryCallCallback<IFriendFinderInvitationResult>(callback, result) || CallbackManager.TryCallCallback<IVirtualGamepadLayoutResult>(callback, result) || CallbackManager.TryCallCallback<IDialogResult>(callback, result) || CallbackManager.TryCallCallback<ILocaleResult>(callback, result) || CallbackManager.TryCallCallback<ISoftKeyboardOpenResult>(callback, result) || CallbackManager.TryCallCallback<IReferralsCreateResult>(callback, result) || CallbackManager.TryCallCallback<IReferralsGetDataResult>(callback, result)) { return; } throw new NotSupportedException("Unexpected result type: " + callback.GetType().FullName); } private static bool TryCallCallback<T>(object callback, IResult result) where T : IResult { var castedCallback = callback as FacebookDelegate<T>; if (castedCallback != null) { castedCallback((T)result); return true; } return false; } } }
129
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using UnityEngine; internal class ComponentFactory { public const string GameObjectName = "UnityFacebookSDKPlugin"; private static GameObject facebookGameObject; internal enum IfNotExist { AddNew, ReturnNull } private static GameObject FacebookGameObject { get { if (facebookGameObject == null) { facebookGameObject = new GameObject(GameObjectName); } return facebookGameObject; } } /** * Gets one and only one component. Lazy creates one if it doesn't exist */ public static T GetComponent<T>(IfNotExist ifNotExist = IfNotExist.AddNew) where T : MonoBehaviour { var facebookGameObject = FacebookGameObject; T component = facebookGameObject.GetComponent<T>(); if (component == null && ifNotExist == IfNotExist.AddNew) { component = facebookGameObject.AddComponent<T>(); } return component; } /** * Creates a new component on the Facebook object regardless if there is already one */ public static T AddComponent<T>() where T : MonoBehaviour { return FacebookGameObject.AddComponent<T>(); } } }
75
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Globalization; using UnityEngine; internal static class Constants { // Callback keys public const string CallbackIdKey = "callback_id"; public const string AccessTokenKey = "access_token"; public const string UrlKey = "url"; public const string RefKey = "ref"; public const string ExtrasKey = "extras"; public const string TargetUrlKey = "target_url"; public const string CancelledKey = "cancelled"; public const string ErrorKey = "error"; public const string HasLicenseKey = "has_license"; // Callback Method Names public const string OnPayCompleteMethodName = "OnPayComplete"; public const string OnShareCompleteMethodName = "OnShareLinkComplete"; public const string OnAppRequestsCompleteMethodName = "OnAppRequestsComplete"; public const string OnGroupCreateCompleteMethodName = "OnGroupCreateComplete"; public const string OnGroupJoinCompleteMethodName = "OnJoinGroupComplete"; // Graph API public const string GraphApiVersion = "v16.0"; public const string GraphUrlFormat = "https://graph.{0}/{1}/"; // Permission Strings public const string UserLikesPermission = "user_likes"; public const string EmailPermission = "email"; public const string PublishActionsPermission = "publish_actions"; public const string PublishPagesPermission = "publish_pages"; // Event Bindings public const string EventBindingKeysClassName = "class_name"; public const string EventBindingKeysIndex = "index"; public const string EventBindingKeysPath = "path"; public const string EventBindingKeysEventName = "event_name"; public const string EventBindingKeysEventType = "event_type"; public const string EventBindingKeysAppVersion = "app_version"; public const string EventBindingKeysText = "text"; public const string EventBindingKeysHint = "hint"; public const string EventBindingKeysDescription = "description"; public const string EventBindingKeysTag = "tag"; public const string EventBindingKeysSection = "section"; public const string EventBindingKeysRow = "row"; public const string EventBindingKeysMatchBitmask = "match_bitmask"; public const int MaxPathDepth = 35; // The current platform. We save this in a variable to allow for // mocking during testing private static FacebookUnityPlatform? currentPlatform; /// <summary> /// Gets the graph URL. /// </summary> /// <value>The graph URL. Ex. https://graph.facebook.com/v3.0/.</value> public static Uri GraphUrl { get { string urlStr = string.Format( CultureInfo.InvariantCulture, Constants.GraphUrlFormat, FB.FacebookDomain, FB.GraphApiVersion); return new Uri(urlStr); } } public static string GraphApiUserAgent { get { // Return the Unity SDK User Agent and our platform user agent return string.Format( CultureInfo.InvariantCulture, "{0} {1}", FB.FacebookImpl.SDKUserAgent, Constants.UnitySDKUserAgent); } } public static bool IsMobile { get { return Constants.CurrentPlatform == FacebookUnityPlatform.Android || Constants.CurrentPlatform == FacebookUnityPlatform.IOS; } } public static bool IsEditor { get { return Application.isEditor; } } public static bool IsWeb { get { return Constants.CurrentPlatform == FacebookUnityPlatform.WebGL; } } /// <summary> /// Gets the legacy user agent suffix that gets /// appended to graph requests on ios and android. /// </summary> /// <value>The user agent unity suffix legacy.</value> public static string UnitySDKUserAgentSuffixLegacy { get { return string.Format( CultureInfo.InvariantCulture, "Unity.{0}", FacebookSdkVersion.Build); } } /// <summary> /// Gets the Unity SDK user agent. /// </summary> public static string UnitySDKUserAgent { get { return Utilities.GetUserAgent("FBUnitySDK", FacebookSdkVersion.Build); } } public static bool DebugMode { get { return Debug.isDebugBuild; } } public static FacebookUnityPlatform CurrentPlatform { get { if (!Constants.currentPlatform.HasValue) { Constants.currentPlatform = Constants.GetCurrentPlatform(); } return Constants.currentPlatform.Value; } set { Constants.currentPlatform = value; } } private static FacebookUnityPlatform GetCurrentPlatform() { switch (Application.platform) { case RuntimePlatform.Android: return FacebookUnityPlatform.Android; case RuntimePlatform.IPhonePlayer: return FacebookUnityPlatform.IOS; case RuntimePlatform.WebGLPlayer: return FacebookUnityPlatform.WebGL; case RuntimePlatform.WindowsPlayer: return FacebookUnityPlatform.Windows; default: return FacebookUnityPlatform.Unknown; } } } }
205
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using System.Linq; /// <summary> /// Contains an amount and currency associated with a purchase or transaction. /// </summary> public class CurrencyAmount { /// <summary> /// Initializes a new instance of the <see cref="CurrencyAmount"/> class. /// </summary> /// <param name="amount">The associated amount.</param> /// <param name="currency">The associated currency.</param> internal CurrencyAmount( string amount, string currency) { this.Amount = amount; this.Currency = currency; } /// <summary> /// Gets the amount, eg "0.99". /// </summary> /// <value>The amount string.</value> public string Amount { get; private set; } /// <summary> /// Gets the currency, represented by the ISO currency code, eg "USD". /// </summary> /// <value>The currency string.</value> public string Currency { get; private set; } /// <summary> /// Returns a <see cref="System.String"/> that represents a <see cref="Facebook.Unity.CurrencyAmount"/>. /// </summary> /// <returns>A <see cref="System.String"/> that represents a <see cref="Facebook.Unity.CurrencyAmount"/>.</returns> public override string ToString() { return Utilities.FormatToString( null, this.GetType().Name, new Dictionary<string, string>() { { "Amount", this.Amount }, { "Currency", this.Currency }, }); } } }
74
facebook-sdk-for-unity
facebook
C#
/* * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System; using System.Collections.Generic; using Facebook.MiniJSON; using UnityEngine; namespace Facebook.Unity { /// <summary> /// Static class to hold Custom Update Content for FBGamingServices.PerformCustomUpdate. /// </summary> public sealed class CustomUpdateContent { public const string CONTEXT_TOKEN_KEY = "context_token_id"; public const string CTA_KEY = "cta"; public const string DATA_KEY = "data"; public const string DEFAULT_KEY = "default"; public const string GIF_KEY = "gif"; public const string IMAGE_KEY = "image"; public const string LOCALIZATIONS_KEY = "localizations"; public const string MEDIA_KEY = "media"; public const string TEXT_KEY = "text"; public const string URL_KEY = "url"; public const string VIDEO_KEY = "video"; private string _contextTokenId; private CustomUpdateLocalizedText _text; private CustomUpdateLocalizedText _cta; private string _image; private CustomUpdateMedia _media; private string _data; private CustomUpdateContent( string contextTokenId, CustomUpdateLocalizedText text, CustomUpdateLocalizedText cta, string image, CustomUpdateMedia media, string data) { _contextTokenId = contextTokenId; _text = text; _cta = cta; _image = image; _media = media; _data = data; } public IDictionary<string, string> toGraphAPIData() { Dictionary<string, string> data = new Dictionary<string, string>(); data.Add(CONTEXT_TOKEN_KEY, _contextTokenId); data.Add(TEXT_KEY, _text.toJson()); if (_cta != null) { data.Add(CTA_KEY, _cta.toJson()); } if (_image != null) { data.Add(IMAGE_KEY, _image); } if (_media != null) { data.Add(MEDIA_KEY, _media.toJson()); } if (_data != null) { data.Add(DATA_KEY, _data); } return data; } public class CustomUpdateContentBuilder { private string _contextTokenId; private CustomUpdateLocalizedText _text; private CustomUpdateLocalizedText _cta; private string _image; private CustomUpdateMedia _media; private string _data; /// <summary> /// Creates a CustomUpdateContent Builder /// </summary> /// <param name="contextTokenId">A valid GamingContext to send the update to</param> /// <param name="text">The text that will be included in the update</param> /// <param name="image">An image that will be included in the update</param> public CustomUpdateContentBuilder( string contextTokenId, CustomUpdateLocalizedText text, Texture2D image) { _contextTokenId = contextTokenId; _text = text; byte[] bytes = image.EncodeToPNG(); _image = "data:image/png;base64," + Convert.ToBase64String(bytes); } /// <summary> /// Creates a CustomUpdateContent Builder /// </summary> /// <param name="contextTokenId">A valid GamingContext to send the update to</param> /// <param name="text">The text that will be included in the update</param> /// <param name="media">A gif or video that will be included in the update</param> public CustomUpdateContentBuilder( string contextTokenId, CustomUpdateLocalizedText text, CustomUpdateMedia media) { _contextTokenId = contextTokenId; _text = text; _media = media; } /// <summary> /// Sets the CTA (Call to Action) text in the update message /// </summary> /// <param name="cta">Custom CTA to use. If none is provided a localized version of 'play' is used.</param> public CustomUpdateContentBuilder setCTA(CustomUpdateLocalizedText cta) { _cta = cta; return this; } /// <summary> /// Sets a Data that will be sent back to the game when a user clicks on the message. When the /// game is launched from a Custom Update message the data here will be forwarded as a Payload. /// </summary> /// <param name="data">A String that will be sent back to the game</param> public CustomUpdateContentBuilder setData(string data) { _data = data; return this; } /// <summary> /// Returns a CustomUpdateContent with the values defined in this builder /// </summary> /// <returns>CustomUpdateContent instance to pass to FBGamingServices.PerformCustomUpdate()</returns> public CustomUpdateContent build() { return new CustomUpdateContent( _contextTokenId, _text, _cta, _image, _media, _data); } } } /// <summary> /// Represents a text string that can have different Locale values provided. /// </summary> public sealed class CustomUpdateLocalizedText { private string _default; private IDictionary<string, string> _localizations; /// <summary> /// Creates a CustomUpdateLocalizedText instance /// </summary> /// <param name="defaultText">Text that will be used if no matching locale is found</param> /// <param name="localizations">Optional key-value Dictionary of Locale_Code: Locale String Value for this text. /// For a list of valid locale codes see: /// https://lookaside.facebook.com/developers/resources/?id=FacebookLocales.xml </param> public CustomUpdateLocalizedText(string defaultText, IDictionary<string, string> localizations) { _default = defaultText; _localizations = localizations; } public string toJson() { Dictionary<string, object> data = new Dictionary<string, object>(); data.Add(CustomUpdateContent.DEFAULT_KEY, _default); if (_localizations != null) { data.Add(CustomUpdateContent.LOCALIZATIONS_KEY, _localizations); } return Json.Serialize(data); } } /// <summary> /// Represents a media that will be included in a Custom Update Message /// </summary> public sealed class CustomUpdateMedia { private CustomUpdateMediaInfo _gif; private CustomUpdateMediaInfo _video; /// <summary> /// Creates a CustomUpdateMedia instance. Note that gif and video are mutually exclusive /// </summary> /// <param name="gif">Gif that will be included in the Update Message</param> /// <param name="video">Video that will be included in the Update Message. Currently this is not yet /// supported but will be in a server side update so it is already included in the SDK. This /// disclaimer will be removed as soon as it is.</param> public CustomUpdateMedia(CustomUpdateMediaInfo gif, CustomUpdateMediaInfo video) { _gif = gif; _video = video; } public string toJson() { Dictionary<string, object> data = new Dictionary<string, object>(); if (_gif != null) { Dictionary<string, string> media = new Dictionary<string, string>(); media.Add(CustomUpdateContent.URL_KEY, _gif.Url); data.Add(CustomUpdateContent.GIF_KEY, media); } if (_video != null) { Dictionary<string, string> media = new Dictionary<string, string>(); media.Add(CustomUpdateContent.URL_KEY, _video.Url); data.Add(CustomUpdateContent.VIDEO_KEY, media); } return Json.Serialize(data); } } /// <summary> /// Stores Information about a Media that will be part of a Custom Update /// </summary> public sealed class CustomUpdateMediaInfo { private string _url; public string Url { get { return _url; } } public CustomUpdateMediaInfo(string url) { _url = url; } } }
261
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using System.Linq; using UnityEngine; internal abstract class FacebookBase : IFacebookImplementation { private InitDelegate onInitCompleteDelegate; protected FacebookBase(CallbackManager callbackManager) { this.CallbackManager = callbackManager; } public abstract bool LimitEventUsage { get; set; } public abstract string SDKName { get; } public abstract string SDKVersion { get; } public virtual string SDKUserAgent { get { return Utilities.GetUserAgent(this.SDKName, this.SDKVersion); } } public virtual bool LoggedIn { get { AccessToken token = AccessToken.CurrentAccessToken; return token != null && token.ExpirationTime > DateTime.UtcNow; } } public bool Initialized { get; set; } protected CallbackManager CallbackManager { get; private set; } public virtual void Init(InitDelegate onInitComplete) { this.onInitCompleteDelegate = onInitComplete; } public abstract void LogInWithPublishPermissions( IEnumerable<string> scope, FacebookDelegate<ILoginResult> callback); public abstract void LogInWithReadPermissions( IEnumerable<string> scope, FacebookDelegate<ILoginResult> callback); public virtual void LogOut() { AccessToken.CurrentAccessToken = null; } public void AppRequest( string message, IEnumerable<string> to = null, IEnumerable<object> filters = null, IEnumerable<string> excludeIds = null, int? maxRecipients = null, string data = "", string title = "", FacebookDelegate<IAppRequestResult> callback = null) { this.AppRequest(message, null, null, to, filters, excludeIds, maxRecipients, data, title, callback); } public abstract void AppRequest( string message, OGActionType? actionType, string objectId, IEnumerable<string> to, IEnumerable<object> filters, IEnumerable<string> excludeIds, int? maxRecipients, string data, string title, FacebookDelegate<IAppRequestResult> callback); public abstract void ShareLink( Uri contentURL, string contentTitle, string contentDescription, Uri photoURL, FacebookDelegate<IShareResult> callback); public abstract void FeedShare( string toId, Uri link, string linkName, string linkCaption, string linkDescription, Uri picture, string mediaSource, FacebookDelegate<IShareResult> callback); public void API( string query, HttpMethod method, IDictionary<string, string> formData, FacebookDelegate<IGraphResult> callback) { IDictionary<string, string> inputFormData; // Copy the formData by value so it's not vulnerable to scene changes and object deletions inputFormData = (formData != null) ? this.CopyByValue(formData) : new Dictionary<string, string>(); if (!inputFormData.ContainsKey(Constants.AccessTokenKey) && !query.Contains("access_token=")) { inputFormData[Constants.AccessTokenKey] = FB.IsLoggedIn ? AccessToken.CurrentAccessToken.TokenString : string.Empty; } FBUnityUtility.AsyncRequestStringWrapper.Request(this.GetGraphUrl(query), method, inputFormData, callback); } public void API( string query, HttpMethod method, WWWForm formData, FacebookDelegate<IGraphResult> callback) { if (formData == null) { formData = new WWWForm(); } string tokenString = (AccessToken.CurrentAccessToken != null) ? AccessToken.CurrentAccessToken.TokenString : string.Empty; formData.AddField( Constants.AccessTokenKey, tokenString); FBUnityUtility.AsyncRequestStringWrapper.Request(this.GetGraphUrl(query), method, formData, callback); } public abstract void ActivateApp(string appId = null); public abstract void GetAppLink(FacebookDelegate<IAppLinkResult> callback); public abstract void AppEventsLogEvent( string logEvent, float? valueToSum, Dictionary<string, object> parameters); public abstract void AppEventsLogPurchase( float logPurchase, string currency, Dictionary<string, object> parameters); public virtual void OnInitComplete(ResultContainer resultContainer) { this.Initialized = true; // Wait for the parsing of login to complete since we may need to pull // in more info about the access token returned FacebookDelegate<ILoginResult> loginCallback = (ILoginResult result) => { if (this.onInitCompleteDelegate != null) { this.onInitCompleteDelegate(); } }; resultContainer.ResultDictionary[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(loginCallback); this.OnLoginComplete(resultContainer); } public abstract void OnLoginComplete(ResultContainer resultContainer); public void OnLogoutComplete(ResultContainer resultContainer) { AccessToken.CurrentAccessToken = null; } public abstract void OnGetAppLinkComplete(ResultContainer resultContainer); public abstract void OnAppRequestsComplete(ResultContainer resultContainer); public abstract void OnShareLinkComplete(ResultContainer resultContainer); protected void ValidateAppRequestArgs( string message, OGActionType? actionType, string objectId, IEnumerable<string> to = null, IEnumerable<object> filters = null, IEnumerable<string> excludeIds = null, int? maxRecipients = null, string data = "", string title = "", FacebookDelegate<IAppRequestResult> callback = null) { if (string.IsNullOrEmpty(message)) { throw new ArgumentNullException("message", "message cannot be null or empty!"); } if (!string.IsNullOrEmpty(objectId) && !(actionType == OGActionType.ASKFOR || actionType == OGActionType.SEND)) { throw new ArgumentNullException("objectId", "objectId must be set if and only if action type is SEND or ASKFOR"); } if (actionType == null && !string.IsNullOrEmpty(objectId)) { throw new ArgumentNullException("actionType", "actionType must be specified if objectId is provided"); } if (to != null && to.Any(toWhom => string.IsNullOrEmpty(toWhom))) { throw new ArgumentNullException("to", "'to' cannot contain any null or empty strings"); } } protected virtual void OnAuthResponse(LoginResult result) { // If the login is cancelled we won't have a access token. // Don't overwrite a valid token if (result.AccessToken != null) { AccessToken.CurrentAccessToken = result.AccessToken; } this.CallbackManager.OnFacebookResponse(result); } private IDictionary<string, string> CopyByValue(IDictionary<string, string> data) { var newData = new Dictionary<string, string>(data.Count); foreach (KeyValuePair<string, string> kvp in data) { newData[kvp.Key] = kvp.Value != null ? new string(kvp.Value.ToCharArray()) : null; } return newData; } private Uri GetGraphUrl(string query) { if (!string.IsNullOrEmpty(query) && query.StartsWith("/")) { query = query.Substring(1); } return new Uri(Constants.GraphUrl, query); } public abstract void GetCatalog(FacebookDelegate<ICatalogResult> callback); public abstract void GetPurchases(FacebookDelegate<IPurchasesResult> callback); public abstract void Purchase(string productID, FacebookDelegate<IPurchaseResult> callback, string developerPayload = ""); public abstract void ConsumePurchase(string productToken, FacebookDelegate<IConsumePurchaseResult> callback); public abstract void GetSubscribableCatalog(FacebookDelegate<ISubscribableCatalogResult> callback); public abstract void GetSubscriptions(FacebookDelegate<ISubscriptionsResult> callback); public abstract void PurchaseSubscription(string productToken, FacebookDelegate<ISubscriptionResult> callback); public abstract void CancelSubscription(string purchaseToken, FacebookDelegate<ICancelSubscriptionResult> callback); public abstract Profile CurrentProfile(); public abstract void CurrentProfile(FacebookDelegate<IProfileResult> callback); public abstract void LoadInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback); public abstract void ShowInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback); public abstract void LoadRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback); public abstract void ShowRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback); public abstract void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback); public abstract void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback); public abstract void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback); public abstract void ScheduleAppToUserNotification(string title, string body, Uri media, int timeInterval, string payload, FacebookDelegate<IScheduleAppToUserNotificationResult> callback); public abstract void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback); public abstract void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback); public abstract void GetTournament(FacebookDelegate<ITournamentResult> callback); public abstract void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback); public abstract void CreateTournament(int initialScore, string title, string imageBase64DataUrl, string sortOrder, string scoreFormat, Dictionary<string, string> data, FacebookDelegate<ITournamentResult> callback); public abstract void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback); public abstract void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback); public void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, string travelId, FacebookDelegate<IMediaUploadResult> callback) { } public void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, string travelId, FacebookDelegate<IMediaUploadResult> callback) { } public abstract void GetUserLocale(FacebookDelegate<ILocaleResult> callback); } }
332
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using UnityEngine; /// <summary> /// Init delegate. /// </summary> public delegate void InitDelegate(); /// <summary> /// Facebook delegate. /// </summary> /// <param name="result">The result.</param> /// <typeparam name="T">The result type.</typeparam> public delegate void FacebookDelegate<T>(T result) where T : IResult; /// <summary> /// Hide unity delegate. /// </summary> /// <param name="isUnityShown">When called with its sole argument set to false, /// your game should pause and prepare to lose focus. If it's called with its /// argument set to true, your game should prepare to regain focus and resume /// play. Your game should check whether it is in fullscreen mode when it resumes, /// and offer the player a chance to go to fullscreen mode if appropriate.</param> public delegate void HideUnityDelegate(bool isUnityShown); internal abstract class FacebookGameObject : MonoBehaviour, IFacebookCallbackHandler { public IFacebookImplementation Facebook { get; set; } public void Awake() { MonoBehaviour.DontDestroyOnLoad(this); AccessToken.CurrentAccessToken = null; // run whatever else needs to be setup this.OnAwake(); } public void OnInitComplete(string message) { this.Facebook.OnInitComplete(new ResultContainer(message)); } public void OnLoginComplete(string message) { this.Facebook.OnLoginComplete(new ResultContainer(message)); } public void OnLogoutComplete(string message) { this.Facebook.OnLogoutComplete(new ResultContainer(message)); } public void OnGetAppLinkComplete(string message) { this.Facebook.OnGetAppLinkComplete(new ResultContainer(message)); } public void OnAppRequestsComplete(string message) { this.Facebook.OnAppRequestsComplete(new ResultContainer(message)); } public void OnShareLinkComplete(string message) { this.Facebook.OnShareLinkComplete(new ResultContainer(message)); } // use this to call the rest of the Awake function protected virtual void OnAwake() { } } }
96
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { /// <summary> /// Facebook sdk version. /// </summary> public class FacebookSdkVersion { /// <summary> /// Gets the SDK build version. /// </summary> /// <value>The sdk version.</value> public static string Build { get { return "16.0.1"; } } } }
41
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { internal enum FacebookUnityPlatform { // Set when running on a platform that we don't // support Unknown, Android, IOS, WebGL, Windows } }
34
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using System.Globalization; using Facebook.Unity.Windows; using Facebook.Unity.Canvas; using Facebook.Unity.Editor; using Facebook.Unity.Mobile; using Facebook.Unity.Mobile.Android; using Facebook.Unity.Mobile.IOS; using Facebook.Unity.Settings; using UnityEngine; /// <summary> /// Static class for exposing the facebook integration. /// </summary> public sealed class FB : ScriptableObject { private const string DefaultJSSDKLocale = "en_US"; private static IFacebook facebook; private static bool isInitCalled = false; private static string facebookDomain = "facebook.com"; private static string gamingDomain = "fb.gg"; private static string graphApiVersion = Constants.GraphApiVersion; private delegate void OnDLLLoaded(); /// <summary> /// Gets the app identifier. AppId might be different from FBSettings.AppId /// if using the programmatic version of FB.Init(). /// </summary> /// <value>The app identifier.</value> public static string AppId { get; private set; } /// <summary> /// Gets the app client token. ClientToken might be different from FBSettings.ClientToken /// if using the programmatic version of FB.Init(). /// </summary> /// <value>The app client token.</value> public static string ClientToken { get; private set; } /// <summary> /// Gets or sets the graph API version. /// The Unity sdk is by default pegged to the lastest version of the graph api /// at the time of the SDKs release. To override this value to use a different /// version set this value. /// <remarks> /// This value is only valid for direct api calls made through FB.Api and the /// graph api version used by the javscript sdk when running on the web. The /// underlyting Android and iOS SDKs will still be pegged to the graph api /// version of this release. /// </remarks> /// </summary> /// <value>The graph API version.</value> public static string GraphApiVersion { get { return FB.graphApiVersion; } set { FB.graphApiVersion = value; } } /// <summary> /// Gets a value indicating whether a user logged in. /// </summary> /// <value><c>true</c> if is logged in; otherwise, <c>false</c>.</value> public static bool IsLoggedIn { get { return (facebook != null) && FacebookImpl.LoggedIn; } } /// <summary> /// Gets a value indicating whether is the SDK is initialized. /// </summary> /// <value><c>true</c> if is initialized; otherwise, <c>false</c>.</value> public static bool IsInitialized { get { return (facebook != null) && facebook.Initialized; } } /// <summary> /// Gets or sets a value indicating whether this <see cref="Facebook.Unity.FB"/> limit app event usage. /// If the player has set the limitEventUsage flag to YES, your app will continue /// to send this data to Facebook, but Facebook will not use the data to serve /// targeted ads. Facebook may continue to use the information for other purposes, /// including frequency capping, conversion events, estimating the number of unique /// users, security and fraud detection, and debugging. /// </summary> /// <value><c>true</c> if limit app event usage; otherwise, <c>false</c>.</value> public static bool LimitAppEventUsage { get { return (facebook != null) && facebook.LimitEventUsage; } set { if (facebook != null) { facebook.LimitEventUsage = value; } } } internal static IFacebook FacebookImpl { get { if (FB.facebook == null) { throw new NullReferenceException("Facebook object is not yet loaded. Did you call FB.Init()?"); } return FB.facebook; } set { FB.facebook = value; } } internal static string FacebookDomain { get { if (FB.IsLoggedIn && AccessToken.CurrentAccessToken != null) { string graphDomain = AccessToken.CurrentAccessToken.GraphDomain; if (graphDomain == "gaming") { return FB.gamingDomain; } } return FB.facebookDomain; } set { FB.facebookDomain = value; } } private static OnDLLLoaded OnDLLLoadedDelegate { get; set; } /// <summary> /// This is the preferred way to call FB.Init(). It will take the facebook app id specified in your "Facebook" /// => "Edit Settings" menu when it is called. /// </summary> /// <param name="onInitComplete"> /// Delegate is called when FB.Init() finished initializing everything. By passing in a delegate you can find /// out when you can safely call the other methods. /// </param> /// <param name="onHideUnity">A delegate to invoke when unity is hidden.</param> /// <param name="authResponse">Auth response.</param> public static void Init(InitDelegate onInitComplete = null, HideUnityDelegate onHideUnity = null, string authResponse = null) { Init( FacebookSettings.AppId, FacebookSettings.ClientToken, FacebookSettings.Cookie, FacebookSettings.Logging, FacebookSettings.Status, FacebookSettings.Xfbml, FacebookSettings.FrictionlessRequests, authResponse, FB.DefaultJSSDKLocale, onHideUnity, onInitComplete); } /// <summary> /// If you need a more programmatic way to set the facebook app id and other setting call this function. /// Useful for a build pipeline that requires no human input. /// </summary> /// <param name="appId">App identifier.</param> /// <param name="clientToken">App client token.</param> /// <param name="cookie">If set to <c>true</c> cookie.</param> /// <param name="logging">If set to <c>true</c> logging.</param> /// <param name="status">If set to <c>true</c> status.</param> /// <param name="xfbml">If set to <c>true</c> xfbml.</param> /// <param name="frictionlessRequests">If set to <c>true</c> frictionless requests.</param> /// <param name="authResponse">Auth response.</param> /// <param name="javascriptSDKLocale"> /// The locale of the js sdk used see /// https://developers.facebook.com/docs/internationalization#plugins. /// </param> /// <param name="onHideUnity"> /// A delegate to invoke when unity is hidden. /// </param> /// <param name="onInitComplete"> /// Delegate is called when FB.Init() finished initializing everything. By passing in a delegate you can find /// out when you can safely call the other methods. /// </param> public static void Init( string appId, string clientToken = null, bool cookie = true, bool logging = true, bool status = true, bool xfbml = false, bool frictionlessRequests = true, string authResponse = null, string javascriptSDKLocale = FB.DefaultJSSDKLocale, HideUnityDelegate onHideUnity = null, InitDelegate onInitComplete = null) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentException("appId cannot be null or empty!"); } FB.AppId = appId; FB.ClientToken = clientToken == null ? FacebookSettings.ClientToken : clientToken; if (!isInitCalled) { isInitCalled = true; if (Constants.IsEditor) { if (Application.platform == RuntimePlatform.WindowsEditor && (FacebookSettings.EditorBuildTarget == FacebookSettings.BuildTarget.StandaloneWindows || FacebookSettings.EditorBuildTarget == FacebookSettings.BuildTarget.StandaloneWindows64)) { FB.OnDLLLoadedDelegate = delegate { ((WindowsFacebook)FB.facebook).Init(appId, FB.ClientToken, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<WindowsFacebookLoader>(); } else { FB.OnDLLLoadedDelegate = delegate { ((EditorFacebook)FB.facebook).Init(onInitComplete); }; ComponentFactory.GetComponent<EditorFacebookLoader>(); ComponentFactory.GetComponent<CodelessCrawler>(); ComponentFactory.GetComponent<CodelessUIInteractEvent>(); } } else { switch (Constants.CurrentPlatform) { case FacebookUnityPlatform.WebGL: FB.OnDLLLoadedDelegate = delegate { ((CanvasFacebook)FB.facebook).Init( appId, cookie, logging, status, xfbml, FacebookSettings.ChannelUrl, authResponse, frictionlessRequests, javascriptSDKLocale, Constants.DebugMode, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<CanvasFacebookLoader>(); break; case FacebookUnityPlatform.IOS: FB.OnDLLLoadedDelegate = delegate { ((IOSFacebook)FB.facebook).Init( appId, frictionlessRequests, FacebookSettings.IosURLSuffix, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<IOSFacebookLoader>(); ComponentFactory.GetComponent<CodelessCrawler>(); ComponentFactory.GetComponent<CodelessUIInteractEvent>(); break; case FacebookUnityPlatform.Android: FB.OnDLLLoadedDelegate = delegate { ((AndroidFacebook)FB.facebook).Init( appId, clientToken, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<AndroidFacebookLoader>(); ComponentFactory.GetComponent<CodelessCrawler>(); ComponentFactory.GetComponent<CodelessUIInteractEvent>(); break; case FacebookUnityPlatform.Windows: FB.OnDLLLoadedDelegate = delegate { ((WindowsFacebook)FB.facebook).Init(appId, clientToken, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<WindowsFacebookLoader>(); break; default: throw new NotSupportedException("The facebook sdk does not support this platform"); } } } else { FacebookLogger.Warn("FB.Init() has already been called. You only need to call this once and only once."); } } /// <summary> /// Logs the user in with the requested publish permissions. /// </summary> /// <param name="permissions">A list of requested permissions.</param> /// <param name="callback">Callback to be called when request completes.</param> /// <exception cref="System.NotSupportedException"> /// Thrown when called on a TV device. /// </exception> public static void LogInWithPublishPermissions( IEnumerable<string> permissions = null, FacebookDelegate<ILoginResult> callback = null) { FacebookImpl.LogInWithPublishPermissions(permissions, callback); } /// <summary> /// Logs the user in with the requested read permissions. /// </summary> /// <param name="permissions">A list of requested permissions.</param> /// <param name="callback">Callback to be called when request completes.</param> /// <exception cref="System.NotSupportedException"> /// Thrown when called on a TV device. /// </exception> public static void LogInWithReadPermissions( IEnumerable<string> permissions = null, FacebookDelegate<ILoginResult> callback = null) { FacebookImpl.LogInWithReadPermissions(permissions, callback); } /// <summary> /// Logs out the current user. /// </summary> public static void LogOut() { FacebookImpl.LogOut(); } /// <summary> /// Apps the request. /// </summary> /// <param name="message">The request string the recipient will see, maximum length 60 characters.</param> /// <param name="actionType">Request action type for structured request.</param> /// <param name="objectId"> /// Open Graph object ID for structured request. /// Note the type of object should belong to this app. /// </param> /// <param name="to">A list of Facebook IDs to which to send the request.</param> /// <param name="data"> /// Additional data stored with the request on Facebook, /// and handed back to the app when it reads the request back out. /// Maximum length 255 characters.</param> /// <param name="title">The title for the platform multi-friend selector dialog. Max length 50 characters..</param> /// <param name="callback">A callback for when the request completes.</param> public static void AppRequest( string message, OGActionType actionType, string objectId, IEnumerable<string> to, string data = "", string title = "", FacebookDelegate<IAppRequestResult> callback = null) { FacebookImpl.AppRequest(message, actionType, objectId, to, null, null, null, data, title, callback); } /// <summary> /// Apps the request. /// </summary> /// <param name="message">The request string the recipient will see, maximum length 60 characters.</param> /// <param name="actionType">Request action type for structured request.</param> /// <param name="objectId"> /// Open Graph object ID for structured request. /// Note the type of object should belong to this app. /// </param> /// <param name="filters"> /// The configuration of the platform multi-friend selector. /// It should be a List of filter strings. /// </param> /// <param name="excludeIds"> /// A list of Facebook IDs to exclude from the platform multi-friend selector dialog. /// This list is currently not supported for mobile devices. /// </param> /// <param name="maxRecipients"> /// Platform-dependent The maximum number of recipients the sender should be able to /// choose in the platform multi-friend selector dialog. /// Only guaranteed to work in Unity Web Player app. /// </param> /// <param name="data"> /// Additional data stored with the request on Facebook, and handed /// back to the app when it reads the request back out. /// Maximum length 255 characters. /// </param> /// <param name="title"> /// The title for the platform multi-friend selector dialog. Max length 50 characters. /// </param> /// <param name="callback">A callback for when the request completes.</param> public static void AppRequest( string message, OGActionType actionType, string objectId, IEnumerable<object> filters = null, IEnumerable<string> excludeIds = null, int? maxRecipients = null, string data = "", string title = "", FacebookDelegate<IAppRequestResult> callback = null) { FacebookImpl.AppRequest(message, actionType, objectId, null, filters, excludeIds, maxRecipients, data, title, callback); } /// <summary> /// Apps the request. /// </summary> /// <param name="message">The request string the recipient will see, maximum length 60 characters.</param> /// <param name="to">A list of Facebook IDs to which to send the request.</param> /// <param name="filters"> /// The configuration of the platform multi-friend selector. /// It should be a List of filter strings. /// </param> /// <param name="excludeIds"> /// A list of Facebook IDs to exclude from the platform multi-friend selector dialog. /// This list is currently not supported for mobile devices. /// </param> /// <param name="maxRecipients"> /// Platform-dependent The maximum number of recipients the sender should be able to /// choose in the platform multi-friend selector dialog. /// Only guaranteed to work in Unity Web Player app. /// </param> /// <param name="data"> /// Additional data stored with the request on Facebook, and handed /// back to the app when it reads the request back out. /// Maximum length 255 characters. /// </param> /// <param name="title"> /// The title for the platform multi-friend selector dialog. Max length 50 characters. /// </param> /// <param name="callback">A callback for when the request completes.</param> public static void AppRequest( string message, IEnumerable<string> to = null, IEnumerable<object> filters = null, IEnumerable<string> excludeIds = null, int? maxRecipients = null, string data = "", string title = "", FacebookDelegate<IAppRequestResult> callback = null) { FacebookImpl.AppRequest(message, null, null, to, filters, excludeIds, maxRecipients, data, title, callback); } /// <summary> /// Opens a share dialog for sharing a link. /// </summary> /// <param name="contentURL">The URL or the link to share.</param> /// <param name="contentTitle">The title to display for this link..</param> /// <param name="contentDescription"> /// The description of the link. If not specified, this field is automatically populated by /// information scraped from the link, typically the title of the page. /// </param> /// <param name="photoURL">The URL of a picture to attach to this content.</param> /// <param name="callback">A callback for when the request completes.</param> public static void ShareLink( Uri contentURL = null, string contentTitle = "", string contentDescription = "", Uri photoURL = null, FacebookDelegate<IShareResult> callback = null) { FacebookImpl.ShareLink( contentURL, contentTitle, contentDescription, photoURL, callback); } /// <summary> /// Legacy feed share. Only use this dialog if you need the legacy parameters otherwiese use /// <see cref="FB.ShareLink(System.String, System.String, System.String, System.String, Facebook.FacebookDelegate"/>. /// </summary> /// <param name="toId"> /// The ID of the profile that this story will be published to. /// If this is unspecified, it defaults to the value of from. /// The ID must be a friend who also uses your app. /// </param> /// <param name="link">The link attached to this post.</param> /// <param name="linkName">The name of the link attachment.</param> /// <param name="linkCaption"> /// The caption of the link (appears beneath the link name). /// If not specified, this field is automatically populated /// with the URL of the link. /// </param> /// <param name="linkDescription"> /// The description of the link (appears beneath the link caption). /// If not specified, this field is automatically populated by information /// scraped from the link, typically the title of the page. /// </param> /// <param name="picture"> /// The URL of a picture attached to this post. /// The picture must be at least 200px by 200px. /// See our documentation on sharing best practices for more information on sizes. /// </param> /// <param name="mediaSource"> /// The URL of a media file (either SWF or MP3) attached to this post. /// If SWF, you must also specify picture to provide a thumbnail for the video. /// </param> /// <param name="callback">The callback to use upon completion.</param> public static void FeedShare( string toId = "", Uri link = null, string linkName = "", string linkCaption = "", string linkDescription = "", Uri picture = null, string mediaSource = "", FacebookDelegate<IShareResult> callback = null) { FacebookImpl.FeedShare( toId, link, linkName, linkCaption, linkDescription, picture, mediaSource, callback); } /// <summary> /// Makes a call to the Facebook Graph API. /// </summary> /// <param name="query"> /// The Graph API endpoint to call. /// You may prefix this with a version string to call a particular version of the API. /// </param> /// <param name="method">The HTTP method to use in the call.</param> /// <param name="callback">The callback to use upon completion.</param> /// <param name="formData">The key/value pairs to be passed to the endpoint as arguments.</param> public static void API( string query, HttpMethod method, FacebookDelegate<IGraphResult> callback = null, IDictionary<string, string> formData = null) { if (string.IsNullOrEmpty(query)) { throw new ArgumentNullException("query", "The query param cannot be null or empty"); } FacebookImpl.API(query, method, formData, callback); } /// <summary> /// Makes a call to the Facebook Graph API. /// </summary> /// <param name="query"> /// The Graph API endpoint to call. /// You may prefix this with a version string to call a particular version of the API. /// </param> /// <param name="method">The HTTP method to use in the call.</param> /// <param name="callback">The callback to use upon completion.</param> /// <param name="formData">Form data for the request.</param> public static void API( string query, HttpMethod method, FacebookDelegate<IGraphResult> callback, WWWForm formData) { if (string.IsNullOrEmpty(query)) { throw new ArgumentNullException("query", "The query param cannot be null or empty"); } FacebookImpl.API(query, method, formData, callback); } /// <summary> /// Sends an app activation event to Facebook when your app is activated. /// /// On iOS and Android, this event is logged automatically if you turn on /// AutoLogAppEventsEnabled flag. You may still need to call this event if /// you are running on web. /// /// On iOS the activate event is fired when the app becomes active /// On Android the activate event is fired during FB.Init /// </summary> public static void ActivateApp() { FacebookImpl.ActivateApp(AppId); } /// <summary> /// Gets the deep link if available. /// </summary> /// <param name="callback">The callback to use upon completion.</param> public static void GetAppLink( FacebookDelegate<IAppLinkResult> callback) { if (callback == null) { // No point in fetching the data if there is no callback return; } FacebookImpl.GetAppLink(callback); } /// <summary> /// Clear app link. /// /// Clear app link when app link has been handled, only works for /// Android, this function will do nothing in other platforms. /// </summary> public static void ClearAppLink() { #if UNITY_ANDROID var androidFacebook = FacebookImpl as AndroidFacebook; if (androidFacebook != null) { androidFacebook.ClearAppLink(); } #endif } /// <summary> /// Logs an app event. /// </summary> /// <param name="logEvent">The name of the event to log.</param> /// <param name="valueToSum">A number representing some value to be summed when reported.</param> /// <param name="parameters">Any parameters needed to describe the event.</param> public static void LogAppEvent( string logEvent, float? valueToSum = null, Dictionary<string, object> parameters = null) { FacebookImpl.AppEventsLogEvent(logEvent, valueToSum, parameters); } /// <summary> /// Logs the purchase. /// </summary> /// <param name="logPurchase">The amount of currency the user spent.</param> /// <param name="currency">The 3-letter ISO currency code.</param> /// <param name="parameters"> /// Any parameters needed to describe the event. /// Elements included in this dictionary can't be null. /// </param> public static void LogPurchase( decimal logPurchase, string currency = null, Dictionary<string, object> parameters = null) { FB.LogPurchase(float.Parse(logPurchase.ToString()), currency, parameters); } /// <summary> /// Logs the purchase. /// </summary> /// <param name="logPurchase">The amount of currency the user spent.</param> /// <param name="currency">The 3-letter ISO currency code.</param> /// <param name="parameters"> /// Any parameters needed to describe the event. /// Elements included in this dictionary can't be null. /// </param> public static void LogPurchase( float logPurchase, string currency = null, Dictionary<string, object> parameters = null) { if (string.IsNullOrEmpty(currency)) { currency = "USD"; } FacebookImpl.AppEventsLogPurchase(logPurchase, currency, parameters); } private static void LogVersion() { // If we have initlized we can also get the underlying sdk version if (facebook != null) { FacebookLogger.Info(string.Format( "Using Facebook Unity SDK v{0} with {1}", FacebookSdkVersion.Build, FB.FacebookImpl.SDKUserAgent)); } else { FacebookLogger.Info(string.Format("Using Facebook Unity SDK v{0}", FacebookSdkVersion.Build)); } } public static void GetCatalog(FacebookDelegate<ICatalogResult> callback) { FacebookImpl.GetCatalog(callback); } public static void GetPurchases(FacebookDelegate<IPurchasesResult> callback) { FacebookImpl.GetPurchases(callback); } public static void Purchase(string productID, FacebookDelegate<IPurchaseResult> callback, string developerPayload = "") { FacebookImpl.Purchase(productID, callback, developerPayload); } public static void ConsumePurchase(string productToken, FacebookDelegate<IConsumePurchaseResult> callback) { FacebookImpl.ConsumePurchase(productToken, callback); } public static void GetSubscribableCatalog(FacebookDelegate<ISubscribableCatalogResult> callback) { FacebookImpl.GetSubscribableCatalog(callback); } public static void GetSubscriptions(FacebookDelegate<ISubscriptionsResult> callback) { FacebookImpl.GetSubscriptions(callback); } public static void PurchaseSubscription(string productID, FacebookDelegate<ISubscriptionResult> callback) { FacebookImpl.PurchaseSubscription(productID, callback); } public static void CancelSubscription(string purchaseToken, FacebookDelegate<ICancelSubscriptionResult> callback) { FacebookImpl.CancelSubscription(purchaseToken, callback); } public static Profile CurrentProfile() { return FacebookImpl.CurrentProfile(); } public static void CurrentProfile(FacebookDelegate<IProfileResult> callback) { FacebookImpl.CurrentProfile(callback); } public static void LoadInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback) { FacebookImpl.LoadInterstitialAd(placementID, callback); } public static void ShowInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback) { FacebookImpl.ShowInterstitialAd(placementID, callback); } public static void LoadRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback) { FacebookImpl.LoadRewardedVideo(placementID, callback); } public static void ShowRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback) { FacebookImpl.ShowRewardedVideo(placementID, callback); } public static void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback) { FacebookImpl.OpenFriendFinderDialog(callback); } public static void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback) { FacebookImpl.GetFriendFinderInvitations(callback); } public static void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback) { FacebookImpl.DeleteFriendFinderInvitation(invitationId, callback); } public static void ScheduleAppToUserNotification(string title, string body, Uri media, int timeInterval, string payload, FacebookDelegate<IScheduleAppToUserNotificationResult> callback) { FacebookImpl.ScheduleAppToUserNotification(title, body, media, timeInterval, payload, callback); } public static void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback) { FacebookImpl.PostSessionScore(score, callback); } public static void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback) { FacebookImpl.PostTournamentScore(score, callback); } public static void GetTournament(FacebookDelegate<ITournamentResult> callback) { FacebookImpl.GetTournament(callback); } public static void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback) { FacebookImpl.ShareTournament(score,data,callback); } public static void CreateTournament( int initialScore, string title, string imageBase64DataUrl, string sortOrder, string scoreFormat, Dictionary<string, string> data, FacebookDelegate<ITournamentResult> callback) { FacebookImpl.CreateTournament(initialScore, title, imageBase64DataUrl, sortOrder, scoreFormat, data, callback); } public static void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback) { FacebookImpl.UploadImageToMediaLibrary(caption, imageUri, shouldLaunchMediaDialog, callback); } public static void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback) { FacebookImpl.UploadVideoToMediaLibrary(caption, videoUri, shouldLaunchMediaDialog, callback); } public static void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, string travelId, FacebookDelegate<IMediaUploadResult> callback) { FacebookImpl.UploadImageToMediaLibrary(caption, imageUri, shouldLaunchMediaDialog, travelId, callback); } public static void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, string travelId, FacebookDelegate<IMediaUploadResult> callback) { FacebookImpl.UploadVideoToMediaLibrary(caption, videoUri, shouldLaunchMediaDialog, travelId, callback); } public static void GetUserLocale(FacebookDelegate<ILocaleResult> callback) { FacebookImpl.GetUserLocale(callback); } /// <summary> /// Contains methods specific to the Facebook Games Canvas platform. /// </summary> public sealed class Canvas { private static IPayFacebook FacebookPayImpl { get { IPayFacebook impl = FacebookImpl as IPayFacebook; if (impl == null) { throw new InvalidOperationException("Attempt to call Facebook pay interface on unsupported platform"); } return impl; } } /// <summary> /// Pay the specified product, action, quantity, quantityMin, quantityMax, requestId, pricepointId, /// testCurrency and callback. /// </summary> /// <param name="product">The URL of your og:product object that the user is looking to purchase.</param> /// <param name="action">Should always be purchaseitem.</param> /// <param name="quantity"> /// The amount of this item the user is looking to purchase - typically used when implementing a virtual currency purchase. /// </param> /// <param name="quantityMin"> /// The minimum quantity of the item the user is able to purchase. /// This parameter is important when handling price jumping to maximize the efficiency of the transaction. /// </param> /// <param name="quantityMax"> /// The maximum quantity of the item the user is able to purchase. /// This parameter is important when handling price jumping to maximize the efficiency of the transaction. /// </param> /// <param name="requestId"> /// The developer defined unique identifier for this transaction, which becomes /// attached to the payment within the Graph API. /// </param> /// <param name="pricepointId"> /// Used to shortcut a mobile payer directly to the /// mobile purchase flow at a given price point. /// </param> /// <param name="testCurrency"> /// This parameter can be used during debugging and testing your implementation to force the dialog to /// use a specific currency rather than the current user's preferred currency. This allows you to /// rapidly prototype your payment experience for different currencies without having to repeatedly /// change your personal currency preference settings. This parameter is only available for admins, /// developers and testers associated with the app, in order to minimize the security risk of a /// malicious JavaScript injection. Provide the 3 letter currency code of the intended forced currency. /// </param> /// <param name="callback">The callback to use upon completion.</param> public static void Pay( string product, string action = "purchaseitem", int quantity = 1, int? quantityMin = null, int? quantityMax = null, string requestId = null, string pricepointId = null, string testCurrency = null, FacebookDelegate<IPayResult> callback = null) { FacebookPayImpl.Pay( product, action, quantity, quantityMin, quantityMax, requestId, pricepointId, testCurrency, callback); } /// <summary> /// Pay the specified productId, action, quantity, quantityMin, quantityMax, requestId, pricepointId, /// testCurrency and callback. /// </summary> /// <param name="productId">The product Id referencing the product managed by Facebook.</param> /// <param name="action">Should always be purchaseiap.</param> /// <param name="quantity"> /// The amount of this item the user is looking to purchase - typically used when implementing a virtual currency purchase. /// </param> /// <param name="quantityMin"> /// The minimum quantity of the item the user is able to purchase. /// This parameter is important when handling price jumping to maximize the efficiency of the transaction. /// </param> /// <param name="quantityMax"> /// The maximum quantity of the item the user is able to purchase. /// This parameter is important when handling price jumping to maximize the efficiency of the transaction. /// </param> /// <param name="requestId"> /// The developer defined unique identifier for this transaction, which becomes /// attached to the payment within the Graph API. /// </param> /// <param name="pricepointId"> /// Used to shortcut a mobile payer directly to the /// mobile purchase flow at a given price point. /// </param> /// <param name="testCurrency"> /// This parameter can be used during debugging and testing your implementation to force the dialog to /// use a specific currency rather than the current user's preferred currency. This allows you to /// rapidly prototype your payment experience for different currencies without having to repeatedly /// change your personal currency preference settings. This parameter is only available for admins, /// developers and testers associated with the app, in order to minimize the security risk of a /// malicious JavaScript injection. Provide the 3 letter currency code of the intended forced currency. /// </param> /// <param name="callback">The callback to use upon completion.</param> public static void PayWithProductId( string productId, string action = "purchaseiap", int quantity = 1, int? quantityMin = null, int? quantityMax = null, string requestId = null, string pricepointId = null, string testCurrency = null, FacebookDelegate<IPayResult> callback = null) { FacebookPayImpl.PayWithProductId( productId, action, quantity, quantityMin, quantityMax, requestId, pricepointId, testCurrency, callback); } /// <summary> /// Pay the specified productId, action, developerPayload, testCurrency and callback. /// </summary> /// <param name="productId">The product Id referencing the product managed by Facebook.</param> /// <param name="action">Should always be purchaseiap.</param> /// <param name="developerPayload"> /// A string that can be used to provide supplemental information about an order. It can be /// used to uniquely identify the purchase request. /// </param> /// <param name="testCurrency"> /// This parameter can be used during debugging and testing your implementation to force the dialog to /// use a specific currency rather than the current user's preferred currency. This allows you to /// rapidly prototype your payment experience for different currencies without having to repeatedly /// change your personal currency preference settings. This parameter is only available for admins, /// developers and testers associated with the app, in order to minimize the security risk of a /// malicious JavaScript injection. Provide the 3 letter currency code of the intended forced currency. /// </param> /// <param name="callback">The callback to use upon completion.</param> public static void PayWithProductId( string productId, string action = "purchaseiap", string developerPayload = null, string testCurrency = null, FacebookDelegate<IPayResult> callback = null) { FacebookPayImpl.PayWithProductId( productId, action, developerPayload, testCurrency, callback); } } /// <summary> /// A class containing the settings specific to the supported mobile platforms. /// </summary> public sealed class Mobile { /// <summary> /// Gets or sets the share dialog mode. /// </summary> /// <value>The share dialog mode.</value> public static ShareDialogMode ShareDialogMode { get { return Mobile.MobileFacebookImpl.ShareDialogMode; } set { Mobile.MobileFacebookImpl.ShareDialogMode = value; } } /// <summary> /// Gets or sets the user ID. /// </summary> /// <value>The user ID.</value> public static string UserID { get { return Mobile.MobileFacebookImpl.UserID; } set { Mobile.MobileFacebookImpl.UserID = value; } } public static void SetDataProcessingOptions(IEnumerable<string> options) { if (options == null) { options = new string[] { }; } Mobile.MobileFacebookImpl.SetDataProcessingOptions(options, 0, 0); } public static void SetDataProcessingOptions(IEnumerable<string> options, int country, int state) { if (options == null) { options = new string[] { }; } Mobile.MobileFacebookImpl.SetDataProcessingOptions(options, country, state); } private static IMobileFacebook MobileFacebookImpl { get { IMobileFacebook impl = FacebookImpl as IMobileFacebook; if (impl == null) { throw new InvalidOperationException("Attempt to call Mobile interface on non mobile platform"); } return impl; } } /// <summary> /// Call this function so that Profile will be automatically updated based on the changes to the access token. /// </summary> public static void EnableProfileUpdatesOnAccessTokenChange(bool enable) { Mobile.MobileFacebookImpl.EnableProfileUpdatesOnAccessTokenChange(enable); } /// <summary> /// Login with tracking experience. /// </summary> /// <param name="loginTracking">The option for login tracking preference, "enabled" or "limited".</param> /// <param name="permissions">A list of permissions.</param> /// <param name="nonce">An optional nonce to use for the login attempt.</param> /// <param name="callback">A callback for when the call is complete.</param> public static void LoginWithTrackingPreference( LoginTracking loginTracking, IEnumerable<string> permissions = null, string nonce = null, FacebookDelegate<ILoginResult> callback = null) { if (loginTracking == LoginTracking.ENABLED) { Mobile.MobileFacebookImpl.LoginWithTrackingPreference("enabled", permissions, nonce, callback); } else { Mobile.MobileFacebookImpl.LoginWithTrackingPreference("limited", permissions, nonce, callback); } } /// <summary> /// Current Authentication Token. /// </summary> public static AuthenticationToken CurrentAuthenticationToken() { return Mobile.MobileFacebookImpl.CurrentAuthenticationToken(); } /// <summary> /// Current Profile. /// </summary> public static Profile CurrentProfile() { return Mobile.MobileFacebookImpl.CurrentProfile(); } /// <summary> /// Current Profile via vallback. /// </summary> public static void CurrentProfile(FacebookDelegate<IProfileResult> callback) { Profile currentProfile = Mobile.MobileFacebookImpl.CurrentProfile(); Dictionary<string, object> result = new Dictionary<string, object>() { { ProfileResult.ProfileKey, currentProfile } }; if (currentProfile == null) { result[Constants.ErrorKey] = "ERROR: No profile data"; } callback.Invoke(new ProfileResult(new ResultContainer(result))); } /// <summary> /// Fetchs the deferred app link data. /// </summary> /// <param name="callback">A callback for when the call is complete.</param> public static void FetchDeferredAppLinkData( FacebookDelegate<IAppLinkResult> callback = null) { if (callback == null) { // No point in fetching the data if there is no callback return; } Mobile.MobileFacebookImpl.FetchDeferredAppLink(callback); } /// <summary> /// Refreshs the current access to get a new access token if possible. /// </summary> /// <param name="callback">A on refresh access token compelte callback.</param> public static void RefreshCurrentAccessToken( FacebookDelegate<IAccessTokenRefreshResult> callback = null) { Mobile.MobileFacebookImpl.RefreshCurrentAccessToken(callback); } /// <summary> /// Returns the setting for Automatic Purchase Logging /// </summary> public static bool IsImplicitPurchaseLoggingEnabled() { return Mobile.MobileFacebookImpl.IsImplicitPurchaseLoggingEnabled(); } /// <summary> /// Sets the setting for Automatic App Events Logging. /// </summary> /// <param name="autoLogAppEventsEnabled">The setting for Automatic App Events Logging</param> public static void SetAutoLogAppEventsEnabled(bool autoLogAppEventsEnabled) { Mobile.MobileFacebookImpl.SetAutoLogAppEventsEnabled(autoLogAppEventsEnabled); } /// <summary> /// Sets the setting for Advertiser ID collection. /// </summary> /// <param name="advertiserIDCollectionEnabled">The setting for Advertiser ID collection</param> public static void SetAdvertiserIDCollectionEnabled(bool advertiserIDCollectionEnabled) { Mobile.MobileFacebookImpl.SetAdvertiserIDCollectionEnabled(advertiserIDCollectionEnabled); } /// <summary> /// Sets the setting for Advertiser Tracking Enabled. /// </summary> /// <param name="advertiserTrackingEnabled">The setting for Advertiser Tracking Enabled</param> public static bool SetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled) { return Mobile.MobileFacebookImpl.SetAdvertiserTrackingEnabled(advertiserTrackingEnabled); } /// <summary> /// Sets device token in the purpose of uninstall tracking. /// </summary> /// <param name="token">The device token from APNs</param> public static void SetPushNotificationsDeviceTokenString(string token) { Mobile.MobileFacebookImpl.SetPushNotificationsDeviceTokenString(token); } public static void GetCatalog(FacebookDelegate<ICatalogResult> callback) { Mobile.MobileFacebookImpl.GetCatalog(callback); } public static void GetPurchases(FacebookDelegate<IPurchasesResult> callback) { Mobile.MobileFacebookImpl.GetPurchases(callback); } public static void Purchase(string productID, FacebookDelegate<IPurchaseResult> callback, string developerPayload = "") { Mobile.MobileFacebookImpl.Purchase(productID, callback, developerPayload); } public static void ConsumePurchase(string productToken, FacebookDelegate<IConsumePurchaseResult> callback) { Mobile.MobileFacebookImpl.ConsumePurchase(productToken, callback); } public static void LoadInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback) { Mobile.MobileFacebookImpl.LoadInterstitialAd(placementID, callback); } public static void ShowInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback) { Mobile.MobileFacebookImpl.ShowInterstitialAd(placementID, callback); } public static void LoadRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback) { Mobile.MobileFacebookImpl.LoadRewardedVideo(placementID, callback); } public static void ShowRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback) { Mobile.MobileFacebookImpl.ShowRewardedVideo(placementID, callback); } public static void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback) { Mobile.MobileFacebookImpl.OpenFriendFinderDialog(callback); } public static void ScheduleAppToUserNotification(string title, string body, Uri media, int timeInterval, string payload, FacebookDelegate<IScheduleAppToUserNotificationResult> callback) { Mobile.MobileFacebookImpl.ScheduleAppToUserNotification(title, body, media, timeInterval, payload, callback); } public static void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback) { Mobile.MobileFacebookImpl.PostSessionScore(score, callback); } public static void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback) { Mobile.MobileFacebookImpl.PostTournamentScore(score, callback); } public static void GetTournament(FacebookDelegate<ITournamentResult> callback) { Mobile.MobileFacebookImpl.GetTournament(callback); } public static void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback) { Mobile.MobileFacebookImpl.ShareTournament(score,data, callback); } public static void GetTournaments(FacebookDelegate<IGetTournamentsResult> callback) { Mobile.MobileFacebookImpl.GetTournaments(callback); } public static void UpdateTournament(string tournamentID, int score, FacebookDelegate<ITournamentScoreResult> callback) { Mobile.MobileFacebookImpl.UpdateTournament(tournamentID, score, callback); } public static void UpdateAndShareTournament(string tournamentID, int score, FacebookDelegate<IDialogResult> callback) { Mobile.MobileFacebookImpl.UpdateAndShareTournament(tournamentID, score, callback); } public static void CreateAndShareTournament( int initialScore, string title, TournamentSortOrder sortOrder, TournamentScoreFormat scoreFormat, DateTime endTime, string payload, FacebookDelegate<IDialogResult> callback) { Mobile.MobileFacebookImpl.CreateAndShareTournament( initialScore, title, sortOrder, scoreFormat, (long)endTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, payload, callback); } public static void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback) { Mobile.MobileFacebookImpl.UploadImageToMediaLibrary(caption, imageUri, shouldLaunchMediaDialog, callback); } public static void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback) { Mobile.MobileFacebookImpl.UploadVideoToMediaLibrary(caption, videoUri, shouldLaunchMediaDialog, callback); } } /// <summary> /// Contains code specific to the Android Platform. /// </summary> public sealed class Android { /// <summary> /// Gets the key hash. /// </summary> /// <value>The key hash.</value> public static string KeyHash { get { var androidFacebook = FacebookImpl as AndroidFacebook; return (androidFacebook != null) ? androidFacebook.KeyHash : string.Empty; } } /// <summary> /// Retrieves the login status for the user. This will return an access token for the app if a user /// is logged into the Facebook for Android app on the same device and that user had previously /// logged into the app.If an access token was retrieved then a toast will be shown telling the /// user that they have been logged in. /// </summary> /// <param name="callback">The callback to be called when the request completes</param> public static void RetrieveLoginStatus(FacebookDelegate<ILoginStatusResult> callback) { var androidFacebook = FacebookImpl as AndroidFacebook; if (androidFacebook != null) { androidFacebook.RetrieveLoginStatus(callback); } } } public sealed class Windows { private static IWindowsFacebook WindowsFacebookImpl { get { IWindowsFacebook impl = FacebookImpl as IWindowsFacebook; if (impl == null) { throw new InvalidOperationException("Attempt to call Windows interface on non Windows platform"); } return impl; } } /// <summary> /// Sets the Virtual Gamepad Layout to use. /// </summary> /// <param name="layout">Name of the layout to use.</param> /// <param name="callback">Callback to be called when request completes.</param> public static void SetVirtualGamepadLayout(string layout, FacebookDelegate<IVirtualGamepadLayoutResult> callback) { Windows.WindowsFacebookImpl.SetVirtualGamepadLayout(layout, callback); } /// <summary> /// Open Virtual Keyboard in mobile devices. /// </summary> /// <param name="open"> true if you want to open the keyboard</param> /// <param name="callback">Callback to be called when request completes.</param> public static void SetSoftKeyboardOpen(bool open, FacebookDelegate<ISoftKeyboardOpenResult> callback) { Windows.WindowsFacebookImpl.SetSoftKeyboardOpen(open, callback); } /// <summary> /// Create a referral link /// </summary> /// <param name="payload">Custom payload to get by the game</param> public static void CreateReferral(string payload, FacebookDelegate<IReferralsCreateResult> callback) { Windows.WindowsFacebookImpl.CreateReferral(payload, callback); } /// <summary> /// Get Data from referral link /// </summary> public static void GetDataReferral(FacebookDelegate<IReferralsGetDataResult> callback) { Windows.WindowsFacebookImpl.GetDataReferral(callback); } } internal abstract class CompiledFacebookLoader : MonoBehaviour { protected abstract FacebookGameObject FBGameObject { get; } public void Start() { FB.facebook = this.FBGameObject.Facebook; FB.OnDLLLoadedDelegate(); FB.LogVersion(); MonoBehaviour.Destroy(this); } } } } public enum TournamentSortOrder { HigherIsBetter, LowerIsBetter } public enum TournamentScoreFormat { Numeric, Time }
1,481
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using System.Globalization; using Facebook.Unity.Canvas; using Facebook.Unity.Editor; using Facebook.Unity.Mobile; using Facebook.Unity.Mobile.Android; using Facebook.Unity.Mobile.IOS; using Facebook.Unity.Settings; using UnityEngine; /// <summary> /// Static class for exposing the Facebook GamingServices Integration. /// </summary> public sealed class FBGamingServices : ScriptableObject { /// <summary> /// Opens the Friend Finder Dialog /// </summary> /// <param name="callback">A callback for when the Dialog is closed.</param> public static void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback) { MobileFacebookImpl.OpenFriendFinderDialog(callback); } /// <summary> /// Uploads an Image to the player's Gaming Media Library /// </summary> /// <param name="caption">Title for this image in the Media Library</param> /// <param name="imageUri">Path to the image file in the local filesystem. On Android /// this can also be a content:// URI</param> /// <param name="shouldLaunchMediaDialog">If we should open the Media Dialog to allow /// the player to Share this image right away.</param> /// <param name="callback">A callback for when the image upload is complete.</param> public static void UploadImageToMediaLibrary( string caption, Uri imageUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback) { MobileFacebookImpl.UploadImageToMediaLibrary(caption, imageUri, shouldLaunchMediaDialog, callback); } /// <summary> /// Uploads a video to the player's Gaming Media Library /// </summary> /// <param name="caption">Title for this video in the Media Library</param> /// <param name="videoUri">Path to the video file in the local filesystem. On Android /// this can also be a content:// URI</param> /// <param name="callback">A callback for when the video upload is complete.</param> /// <remarks>Note that when the callback is fired, the video will still need to be /// encoded before it is available in the Media Library.</remarks> public static void UploadVideoToMediaLibrary( string caption, Uri videoUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback) { MobileFacebookImpl.UploadVideoToMediaLibrary(caption, videoUri, shouldLaunchMediaDialog, callback); } /// <summary> /// Informs facebook that the player has taken an action and will notify other players in the same GamingContext /// </summary> /// <param name="content">Please check CustomUpdateContent.Builder for details on all the fields that /// allow customizing the update.</param> /// <param name="callback">The callback to use upon completion.</param> public static void PerformCustomUpdate( CustomUpdateContent content, FacebookDelegate<IGraphResult> callback = null) { FB.API("/me/custom_update", HttpMethod.POST, callback, content.toGraphAPIData()); } public static void OnIAPReady(FacebookDelegate<IIAPReadyResult> callback) { MobileFacebookImpl.OnIAPReady(callback); } public static void GetCatalog(FacebookDelegate<ICatalogResult> callback) { MobileFacebookImpl.GetCatalog(callback); } public static void GetPurchases(FacebookDelegate<IPurchasesResult> callback) { MobileFacebookImpl.GetPurchases(callback); } public static void Purchase(string productID, FacebookDelegate<IPurchaseResult> callback, string developerPayload = "") { MobileFacebookImpl.Purchase(productID, callback, developerPayload); } public static void ConsumePurchase(string purchaseToken, FacebookDelegate<IConsumePurchaseResult> callback) { MobileFacebookImpl.ConsumePurchase(purchaseToken, callback); } public static void GetSubscribableCatalog(FacebookDelegate<ISubscribableCatalogResult> callback) { MobileFacebookImpl.GetSubscribableCatalog(callback); } public static void GetSubscriptions(FacebookDelegate<ISubscriptionsResult> callback) { MobileFacebookImpl.GetSubscriptions(callback); } public static void PurchaseSubscription(string productID, FacebookDelegate<ISubscriptionResult> callback) { MobileFacebookImpl.PurchaseSubscription(productID, callback); } public static void CancelSubscription(string purchaseToken, FacebookDelegate<ICancelSubscriptionResult> callback) { MobileFacebookImpl.CancelSubscription(purchaseToken, callback); } public static void InitCloudGame( FacebookDelegate<IInitCloudGameResult> callback) { MobileFacebookImpl.InitCloudGame(callback); } public static void GameLoadComplete( FacebookDelegate<IGameLoadCompleteResult> callback) { MobileFacebookImpl.GameLoadComplete(callback); } public static void ScheduleAppToUserNotification( string title, string body, Uri media, int timeInterval, string payload, FacebookDelegate<IScheduleAppToUserNotificationResult> callback) { MobileFacebookImpl.ScheduleAppToUserNotification(title, body, media, timeInterval, payload, callback); } public static void LoadInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback) { MobileFacebookImpl.LoadInterstitialAd(placementID, callback); } public static void ShowInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback) { MobileFacebookImpl.ShowInterstitialAd(placementID, callback); } public static void LoadRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback) { MobileFacebookImpl.LoadRewardedVideo(placementID, callback); } public static void ShowRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback) { MobileFacebookImpl.ShowRewardedVideo(placementID, callback); } public static void GetPayload(FacebookDelegate<IPayloadResult> callback) { MobileFacebookImpl.GetPayload(callback); } public static void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback) { MobileFacebookImpl.PostSessionScore(score, callback); } public static void GetTournament(FacebookDelegate<ITournamentResult> callback) { MobileFacebookImpl.GetTournament(callback); } public static void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback) { MobileFacebookImpl.ShareTournament(score, data, callback); } public static void CreateTournament( int initialScore, string title, string imageBase64DataUrl, string sortOrder, string scoreFormat, Dictionary<string, string> data, FacebookDelegate<ITournamentResult> callback) { MobileFacebookImpl.CreateTournament(initialScore, title, imageBase64DataUrl, sortOrder, scoreFormat, data, callback); } public static void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback) { MobileFacebookImpl.PostTournamentScore(score, callback); } public static void OpenAppStore(FacebookDelegate<IOpenAppStoreResult> callback) { MobileFacebookImpl.OpenAppStore(callback); } public static void CreateGamingContext(string playerID, FacebookDelegate<ICreateGamingContextResult> callback) { MobileFacebookImpl.CreateGamingContext(playerID, callback); } public static void SwitchGamingContext(string gamingContextID, FacebookDelegate<ISwitchGamingContextResult> callback) { MobileFacebookImpl.SwitchGamingContext(gamingContextID, callback); } public static void ChooseGamingContext(List<string> filters, int minSize, int maxSize, FacebookDelegate<IChooseGamingContextResult> callback) { MobileFacebookImpl.ChooseGamingContext(filters, minSize, maxSize, callback); } public static void GetCurrentGamingContext(FacebookDelegate<IGetCurrentGamingContextResult> callback) { MobileFacebookImpl.GetCurrentGamingContext(callback); } private static IMobileFacebook MobileFacebookImpl { get { IMobileFacebook impl = FB.FacebookImpl as IMobileFacebook; if (impl == null) { throw new InvalidOperationException("Attempt to call Mobile interface on non mobile platform"); } return impl; } } } }
247
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System.Collections.Generic; public class FBLocation { internal FBLocation(string id, string name) { this.ID = id; this.Name = name; } /// <summary> /// Gets the location's unique identifier /// </summary> /// <value>location's unique identifier.</value> public string ID { get; private set; } /// <summary> /// Gets the location's name. /// </summary> /// <value>The location's name.</value> public string Name { get; private set; } internal static FBLocation FromDictionary(string prefix, IDictionary<string, string> dictionary) { string id; string name; dictionary.TryGetValue(prefix + "_id", out id); dictionary.TryGetValue(prefix + "_name", out name); if (id == null || name == null) { return null; } return new FBLocation(id, name); } /// <summary> /// Returns a <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.FBLocation"/>. /// </summary> /// <returns>A <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.FBLocation"/>.</returns> public override string ToString() { return Utilities.FormatToString( null, this.GetType().Name, new Dictionary<string, string>() { { "id", this.ID}, { "name", this.Name}, }); } } }
75
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using System.Linq; /// <summary> /// Contains a Inviation from Friend Finder. /// </summary> public class FriendFinderInviation { internal FriendFinderInviation( string id, string applicationId, string applicationName, string fromId, string fromName, string toId, string toName, string message, string createdTime) { this.Id = sanityCheckParam(id, "id"); this.ApplicationId = sanityCheckParam(applicationId, "applicationId"); this.ApplicationName = sanityCheckParam(applicationName, "applicationName"); this.FromId = sanityCheckParam(fromId, "fromId"); this.FromName = sanityCheckParam(fromName, "fromName"); this.ToId = sanityCheckParam(toId, "toId"); this.ToName = sanityCheckParam(toName, "toName"); this.Message = message; this.CreatedTime = sanityCheckParam(createdTime, "createdTime"); } private string sanityCheckParam(string param, string errorMsg) { if (string.IsNullOrEmpty(param)) { throw new ArgumentNullException(errorMsg); } return param; } public string Id { get; private set; } public string ApplicationId { get; private set; } public string ApplicationName { get; private set; } public string FromId { get; private set; } public string FromName { get; private set; } public string ToId { get; private set; } public string ToName { get; private set; } public string Message { get; private set; } public string CreatedTime { get; private set; } } }
85
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using UnityEngine; internal interface IFacebook: IFacebookWindows { bool LoggedIn { get; } bool LimitEventUsage { get; set; } string SDKName { get; } string SDKVersion { get; } string SDKUserAgent { get; } bool Initialized { get; set; } void LogInWithPublishPermissions( IEnumerable<string> permissions, FacebookDelegate<ILoginResult> callback); void LogInWithReadPermissions( IEnumerable<string> permissions, FacebookDelegate<ILoginResult> callback); void LogOut(); [Obsolete] void AppRequest( string message, IEnumerable<string> to, IEnumerable<object> filters, IEnumerable<string> excludeIds, int? maxRecipients, string data, string title, FacebookDelegate<IAppRequestResult> callback); void AppRequest( string message, OGActionType? actionType, string objectId, IEnumerable<string> to, IEnumerable<object> filters, IEnumerable<string> excludeIds, int? maxRecipients, string data, string title, FacebookDelegate<IAppRequestResult> callback); void ShareLink( Uri contentURL, string contentTitle, string contentDescription, Uri photoURL, FacebookDelegate<IShareResult> callback); void FeedShare( string toId, Uri link, string linkName, string linkCaption, string linkDescription, Uri picture, string mediaSource, FacebookDelegate<IShareResult> callback); void API( string query, HttpMethod method, IDictionary<string, string> formData, FacebookDelegate<IGraphResult> callback); void API( string query, HttpMethod method, WWWForm formData, FacebookDelegate<IGraphResult> callback); void ActivateApp(string appId = null); void GetAppLink(FacebookDelegate<IAppLinkResult> callback); void AppEventsLogEvent( string logEvent, float? valueToSum, Dictionary<string, object> parameters); void AppEventsLogPurchase( float logPurchase, string currency, Dictionary<string, object> parameters); void GetCatalog(FacebookDelegate<ICatalogResult> callback); void GetPurchases(FacebookDelegate<IPurchasesResult> callback); void Purchase(string productID, FacebookDelegate<IPurchaseResult> callback, string developerPayload = ""); void ConsumePurchase(string productToken, FacebookDelegate<IConsumePurchaseResult> callback); void GetSubscribableCatalog(FacebookDelegate<ISubscribableCatalogResult> callback); void GetSubscriptions(FacebookDelegate<ISubscriptionsResult> callback); void PurchaseSubscription(string productToken, FacebookDelegate<ISubscriptionResult> callback); void CancelSubscription(string purchaseToken, FacebookDelegate<ICancelSubscriptionResult> callback); Profile CurrentProfile(); void CurrentProfile(FacebookDelegate<IProfileResult> callback); void LoadInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback); void ShowInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback); void LoadRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback); void ShowRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback); void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback); void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback); void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback); void ScheduleAppToUserNotification(string title, string body, Uri media, int timeInterval, string payload, FacebookDelegate<IScheduleAppToUserNotificationResult> callback); void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback); void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback); void GetTournament(FacebookDelegate<ITournamentResult> callback); void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback); void CreateTournament( int initialScore, string title, string imageBase64DataUrl, string sortOrder, string scoreFormat, Dictionary<string, string> data, FacebookDelegate<ITournamentResult> callback); void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback); void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback); void GetUserLocale(FacebookDelegate<ILocaleResult> callback); } internal interface IFacebookWindows { void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, string travelId, FacebookDelegate<IMediaUploadResult> callback); void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, string travelId, FacebookDelegate<IMediaUploadResult> callback); } }
183
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { internal interface IFacebookCallbackHandler { void OnInitComplete(string message); void OnLoginComplete(string message); void OnLogoutComplete(string message); void OnGetAppLinkComplete(string message); void OnAppRequestsComplete(string message); void OnShareLinkComplete(string message); } }
38
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { internal interface IFacebookImplementation : IFacebook, IFacebookResultHandler { } }
27
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System.Collections.Generic; internal interface IFacebookResultHandler { void OnInitComplete(ResultContainer resultContainer); void OnLoginComplete(ResultContainer resultContainer); void OnLogoutComplete(ResultContainer resultContainer); void OnGetAppLinkComplete(ResultContainer resultContainer); void OnAppRequestsComplete(ResultContainer resultContainer); void OnShareLinkComplete(ResultContainer resultContainer); } }
40
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { internal interface IPayFacebook { void Pay( string product, string action, int quantity, int? quantityMin, int? quantityMax, string requestId, string pricepointId, string testCurrency, FacebookDelegate<IPayResult> callback); void PayWithProductId( string productId, string action, int quantity, int? quantityMin, int? quantityMax, string requestId, string pricepointId, string testCurrency, FacebookDelegate<IPayResult> callback); void PayWithProductId( string productId, string action, string developerPayload, string testCurrency, FacebookDelegate<IPayResult> callback); } }
55
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { public enum LoginTracking { ENABLED, LIMITED } }
29
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; internal class MethodArguments { private IDictionary<string, object> arguments = new Dictionary<string, object>(); public MethodArguments() : this(new Dictionary<string, object>()) { } public MethodArguments(MethodArguments methodArgs) : this(methodArgs.arguments) { } private MethodArguments(IDictionary<string, object> arguments) { this.arguments = arguments; } public void AddPrimative<T>(string argumentName, T value) where T : struct { this.arguments[argumentName] = value; } public void AddNullablePrimitive<T>(string argumentName, T? nullable) where T : struct { if (nullable != null && nullable.HasValue) { this.arguments[argumentName] = nullable.Value; } } public void AddString(string argumentName, string value) { if (!string.IsNullOrEmpty(value)) { this.arguments[argumentName] = value; } } public void AddCommaSeparatedList(string argumentName, IEnumerable<string> value) { if (value != null) { this.arguments[argumentName] = value.ToCommaSeparateList(); } } public void AddDictionary(string argumentName, IDictionary<string, object> dict) { if (dict != null) { this.arguments[argumentName] = MethodArguments.ToStringDict(dict); } } public void AddList<T>(string argumentName, IEnumerable<T> list) { if (list != null) { this.arguments[argumentName] = list; } } public void AddUri(string argumentName, Uri uri) { if (uri != null && !string.IsNullOrEmpty(uri.AbsoluteUri)) { this.arguments[argumentName] = uri.ToString(); } } public string ToJsonString() { return MiniJSON.Json.Serialize(this.arguments); } private static Dictionary<string, string> ToStringDict(IDictionary<string, object> dict) { if (dict == null) { return null; } var newDict = new Dictionary<string, string>(); foreach (KeyValuePair<string, object> kvp in dict) { newDict[kvp.Key] = kvp.Value.ToString(); } return newDict; } } }
118
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System.Collections; using System.Collections.Generic; internal abstract class MethodCall<T> where T : IResult { public MethodCall(FacebookBase facebookImpl, string methodName) { this.Parameters = new MethodArguments(); this.FacebookImpl = facebookImpl; this.MethodName = methodName; } public string MethodName { get; private set; } public FacebookDelegate<T> Callback { protected get; set; } protected FacebookBase FacebookImpl { get; set; } protected MethodArguments Parameters { get; set; } public abstract void Call(MethodArguments args = null); } }
46
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { /// <summary> /// Share dialog mode. /// </summary> public enum ShareDialogMode { // If you make changes in here make the same changes in Assets/Facebook/Editor/iOS/FBUnityInterface.h /// <summary> /// The sdk will choose which type of dialog to show /// See the Facebook SDKs for ios and android for specific details. /// </summary> AUTOMATIC = 0, /// <summary> /// Uses the dialog inside the native facebook applications. Note this will fail if the /// native applications are not installed. /// </summary> NATIVE = 1, /// <summary> /// Opens the facebook dialog in a webview. /// </summary> WEB = 2, /// <summary> /// Uses the feed dialog. /// </summary> FEED = 3, } }
53
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { /// <summary> /// OG action type. /// </summary> public enum OGActionType { /// <summary> /// SEND Action. /// </summary> SEND, /// <summary> /// ASKFOR Action. /// </summary> ASKFOR, /// <summary> /// TURN Action. /// </summary> TURN, } }
44
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; using System.Linq; /// <summary> /// Contains a Instant Game Product. /// </summary> public class Product { /// <summary> /// Initializes a new instance of the <see cref="Product"/> class. /// </summary> /// <param name="title">The title of the product.</param> /// <param name="productID">The product's game-specified identifier.</param> /// <param name="description">The product description.</param> /// <param name="imageURI">A link to the product's associated image.</param> /// <param name="price">The price of the product.</param> /// <param name="priceAmount">The numeric price of a product.</param> /// <param name="priceCurrencyCode">The currency code for the product.</param> internal Product( string title, string productID, string description, string imageURI, string price, double? priceAmount, string priceCurrencyCode) { if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException("title"); } if (string.IsNullOrEmpty(productID)) { throw new ArgumentNullException("productID"); } if (string.IsNullOrEmpty(price)) { throw new ArgumentException("price"); } if (string.IsNullOrEmpty(priceCurrencyCode)) { throw new ArgumentNullException("priceCurrencyCode"); } this.Title = title; this.ProductID = productID; this.Description = description; this.ImageURI = imageURI; this.Price = price; this.PriceAmount = priceAmount; this.PriceCurrencyCode = priceCurrencyCode; } /// <summary> /// Gets the title. /// </summary> /// <value>The title.</value> public string Title { get; private set; } /// <summary> /// Gets the product identifier. /// </summary> /// <value>The product identifier.</value> public string ProductID { get; private set; } /// <summary> /// Gets the description. /// </summary> /// <value>The description.</value> public string Description { get; private set; } /// <summary> /// Gets the image uniform resource identifier. /// </summary> /// <value>The image uniform resource identifier.</value> public string ImageURI { get; private set; } /// <summary> /// Gets the price. /// </summary> /// <value>The price.</value> public string Price { get; private set; } /// <summary> /// Gets the price amount. /// </summary> /// <value>The price amount.</value> public double? PriceAmount { get; private set; } /// <summary> /// Gets the price currency code. /// </summary> /// <value>The price currency code.</value> public string PriceCurrencyCode { get; private set; } /// <summary> /// Returns a <see cref="System.String"/> that represents a <see cref="Facebook.Unity.Product"/>. /// </summary> /// <returns>A <see cref="System.String"/> that represents a <see cref="Facebook.Unity.Product"/>.</returns> public override string ToString() { return Utilities.FormatToString( null, this.GetType().Name, new Dictionary<string, string>() { { "Title", this.Title }, { "ProductID", this.ProductID }, { "Description", this.Description.ToStringNullOk() }, { "ImageURI", this.ImageURI.ToStringNullOk() }, { "Price", this.Price }, { "PriceAmount", this.PriceAmount.ToStringNullOk() }, { "PriceCurrencyCode", this.PriceCurrencyCode }, }); } } }
144
facebook-sdk-for-unity
facebook
C#
/** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, * copy, modify, and distribute this software in source code or binary form for use * in connection with the web services and APIs provided by Facebook. * * As with any software that integrates with the Facebook platform, your use of * this software is subject to the Facebook Developer Principles and Policies * [http://developers.facebook.com/policy/]. This copyright notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Facebook.Unity { using System; using System.Collections.Generic; public class Profile { /// <summary> /// Initializes a new instance of the <see cref="Profile"/> class. /// </summary> /// <param name="userID">User ID.</param> /// <param name="firstName">First Name.</param> /// <param name="middleName">Middle Name.</param> /// <param name="lastName">Last Name.</param> /// <param name="name">Name.</param> /// <param name="email">Email.</param> /// <param name="imageURL">Image URL.</param> /// <param name="linkURL">Link URL.</param> /// <param name="friendIDs">A list of identifiers for the user's friends.</param> /// <param name="birthday">User's birthday</param> /// <param name="ageRange">Age Range for the User</param> /// <param name="hometown">Home Town</param> /// <param name="location">Location</param> /// <param name="gender">Gender</param> internal Profile( string userID, string firstName, string middleName, string lastName, string name, string email, string imageURL, string linkURL, string[] friendIDs, string birthday, UserAgeRange ageRange, FBLocation hometown, FBLocation location, string gender) { this.UserID = userID; this.FirstName = firstName; this.MiddleName = middleName; this.LastName = lastName; this.Name = name; this.Email = email; this.ImageURL = imageURL; this.LinkURL = linkURL; this.FriendIDs = friendIDs ?? new string[] { }; long birthdayTimestamp; if (long.TryParse(birthday, out birthdayTimestamp)) { this.Birthday = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) .AddMilliseconds(birthdayTimestamp * 1000) .ToLocalTime(); } this.AgeRange = ageRange; this.Hometown = hometown; this.Location = location; this.Gender = gender; } /// <summary> /// Gets the user ID. /// </summary> /// <value>The user ID.</value> public string UserID { get; private set; } /// <summary> /// Gets the fist name. /// </summary> /// <value>The fist name.</value> public string FirstName { get; private set; } /// <summary> /// Gets the middle name. /// </summary> /// <value>The middle name.</value> public string MiddleName { get; private set; } /// <summary> /// Gets the last name. /// </summary> /// <value>The last name.</value> public string LastName { get; private set; } /// <summary> /// Gets the name. /// </summary> /// <value>The name.</value> public string Name { get; private set; } /// <summary> /// Gets the email. /// </summary> /// <value>The email.</value> public string Email { get; private set; } /// <summary> /// Gets the image URL. /// </summary> /// <value>The image URL.</value> public string ImageURL { get; private set; } /// <summary> /// Gets the link URL. /// </summary> /// <value>The link url.</value> public string LinkURL { get; private set; } /// <summary> /// Gets the list of identifiers for the user's friends. /// </summary> /// <value>The list of identifiers for the user's friends.</value> public string[] FriendIDs { get; private set; } /// <summary> /// Gets the user's birthday. /// </summary> /// <value>The user's birthday.</value> public DateTime? Birthday { get; private set; } /// <summary> /// Gets the user's age range. /// </summary> /// <value>The user's age range.</value> public UserAgeRange AgeRange { get; private set; } /// <summary> /// Gets the user's hometown /// </summary> /// <value>The user's hometown</value> public FBLocation Hometown { get; private set; } /// <summary> /// Gets the user's location /// </summary> /// <value>The user's location </value> public FBLocation Location { get; private set; } /// <summary> /// Gets the user's gender /// </summary> /// <value>The user's gender</value> public string Gender { get; private set; } /// <summary> /// Returns a <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.Profile"/>. /// </summary> /// <returns>A <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.Profile"/>.</returns> public override string ToString() { return Utilities.FormatToString( null, this.GetType().Name, new Dictionary<string, string>() { { "UserID", this.UserID}, { "FirstName", this.FirstName }, { "MiddleName", this.MiddleName}, { "LastName", this.LastName }, { "Name", this.Name}, { "Email", this.Email }, { "ImageURL", this.ImageURL}, { "LinkURL", this.LinkURL }, { "FriendIDs", String.Join(",", this.FriendIDs) }, { "Birthday", this.Birthday?.ToShortDateString()}, { "AgeRange", this.AgeRange?.ToString()}, { "Hometown", this.Hometown?.ToString() }, { "Location", this.Location?.ToString() }, { "Gender", this.Gender }, }); } } }
197
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card