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 |
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 Purchase.
/// </summary>
public class Purchase
{
/// <summary>
/// Initializes a new instance of the <see cref="Purchase"/> class.
/// </summary>
/// <param name="developerPayload">A developer-specified string, provided during the purchase of the product.</param>
/// <param name="isConsumed">Whether or not the purchase has been consumed.</param>
/// <param name="paymentActionType">The current status of the purchase.</param>
/// <param name="paymentID">The identifier for the purchase transaction.</param>
/// <param name="productID">The product's game-specified identifier.</param>
/// <param name="purchasePlatform">The purchase platform, such as "GOOGLE" or "FB".</param>
/// <param name="purchasePrice">Contains the local amount and currency associated with the purchased item.</param>
/// <param name="purchaseTime">Unix timestamp of when the purchase occurred.</param>
/// <param name="purchaseToken">A token representing the purchase that may be used to consume the purchase.</param>
/// <param name="signedRequest">Server-signed encoding of the purchase request.</param>
internal Purchase(
string developerPayload,
bool isConsumed,
string paymentActionType,
string paymentID,
string productID,
string purchasePlatform,
IDictionary<string, object> purchasePrice,
long purchaseTime,
string purchaseToken,
string signedRequest)
{
if (string.IsNullOrEmpty(paymentActionType))
{
throw new ArgumentNullException("paymentActionType");
}
if (string.IsNullOrEmpty(paymentID))
{
throw new ArgumentNullException("paymentID");
}
if (string.IsNullOrEmpty(productID))
{
throw new ArgumentNullException("productID");
}
int purchaseTimeInt;
try {
purchaseTimeInt = Convert.ToInt32(purchaseTime);
} catch (OverflowException) {
throw new ArgumentException("purchaseTime");
}
if (string.IsNullOrEmpty(purchaseToken))
{
throw new ArgumentNullException("purchaseToken");
}
if (string.IsNullOrEmpty(signedRequest))
{
throw new ArgumentNullException("signedRequest");
}
this.DeveloperPayload = developerPayload;
this.PaymentActionType = paymentActionType;
this.PaymentID = paymentID;
this.ProductID = productID;
this.PurchasePlatform = purchasePlatform;
this.PurchasePrice = new CurrencyAmount(purchasePrice["currency"].ToStringNullOk(), purchasePrice["amount"].ToStringNullOk());
this.PurchaseTime = Utilities.FromTimestamp(purchaseTimeInt);
this.PurchaseToken = purchaseToken;
this.SignedRequest = signedRequest;
}
/// <summary>
/// Gets the developer payload string.
/// </summary>
/// <value>The developer payload string.</value>
public string DeveloperPayload { get; private set; }
/// <summary>
/// Gets whether or not the purchase has been consumed.
/// </summary>
/// <value>The consumed boolean.</value>
public bool IsConsumed { get; private set; }
/// <summary>
/// Gets the purchase status.
/// </summary>
/// <value>The purchase status.</value>
public string PaymentActionType { get; private set; }
/// <summary>
/// Gets the purchase identifier.
/// </summary>
/// <value>The purchase identifier.</value>
public string PaymentID { get; private set; }
/// <summary>
/// Gets the product identifier.
/// </summary>
/// <value>The product identifier.</value>
public string ProductID { get; private set; }
/// <summary>
/// Gets the platform associated with the purchase.
/// </summary>
/// <value>The purchase platform, such as "GOOGLE" or "FB".</value>
public string PurchasePlatform { get; private set; }
/// <summary>
/// Gets the amount and currency fields associated with the purchase.
/// </summary>
/// <value>The amount and currency fields associated with the purchase as a CurrencyAmount</value>
public CurrencyAmount PurchasePrice { get; private set; }
/// <summary>
/// Gets the purchase time.
/// </summary>
/// <value>The purchase time.</value>
public DateTime PurchaseTime { get; private set; }
/// <summary>
/// Gets the purchase token.
/// </summary>
/// <value>The purchase token.</value>
public string PurchaseToken { get; private set; }
/// <summary>
/// Gets the price currency code.
/// </summary>
/// <value>The price currency code.</value>
public string SignedRequest { get; private set; }
/// <summary>
/// Returns a <see cref="System.String"/> that represents a <see cref="Facebook.Unity.Purchase"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents a <see cref="Facebook.Unity.Purchase"/>.</returns>
public override string ToString()
{
return Utilities.FormatToString(
null,
this.GetType().Name,
new Dictionary<string, string>()
{
{ "DeveloperPayload", this.DeveloperPayload.ToStringNullOk() },
{ "IsConsumed", this.IsConsumed.ToStringNullOk() },
{ "PaymentActionType", this.PaymentActionType },
{ "PaymentID", this.PaymentID },
{ "ProductID", this.ProductID },
{ "PurchasePlatform", this.PurchasePlatform },
{ "PurchasePrice", this.PurchasePrice.ToString() },
{ "PurchaseTime", this.PurchaseTime.TotalSeconds().ToString() },
{ "PurchaseToken", this.PurchaseToken },
{ "SignedRequest", this.SignedRequest },
});
}
}
}
| 185 |
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 SubscribableProduct
{
/// <summary>
/// Initializes a new instance of the <see cref="SubscribableProduct"/> 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>
/// <param name="subscriptionTerm">The billing cycle of a subscription.</param>
internal SubscribableProduct(
string title,
string productID,
string description,
string imageURI,
string price,
double? priceAmount,
string priceCurrencyCode,
string subscriptionTerm)
{
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");
}
if (string.IsNullOrEmpty(subscriptionTerm))
{
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;
this.SubscriptionTerm = subscriptionTerm;
}
/// <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>
/// Gets the subscription term.
/// </summary>
/// <value>The subscription term.</value>
public string SubscriptionTerm { 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 },
{ "SubscriptionTerm", this.SubscriptionTerm },
});
}
}
}
| 159 |
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>
/// Represents the purchase of a subscription.
/// </summary>
public class Subscription
{
/// <summary>
/// Initializes a new instance of the <see cref="Subscription"/> class.
/// </summary>
/// <param name="deactivationTime">The Unix timestamp of when the subscription entitlement will no longer be active,
/// if subscription is not renewed or is canceled. Otherwise, null </param>
/// <param name="isEntitlementActive">Whether or not the user is an active subscriber and should receive entitlement
/// to the subscription benefits.</param>
/// <param name="periodStartTime">The current start Unix timestamp of the latest billing cycle.</param>
/// <param name="periodEndTime">The current end Unix timestamp of the latest billing cycle.</param>
/// <param name="productID">The corresponding subscribable product's game-specified identifier.</param>
/// <param name="purchasePlatform">The platform associated with the purchase, such as "FB" for Facebook and "GOOGLE" for Google.</param>
/// <param name="purchasePrice">Contains the local amount and currency.</param>
/// <param name="purchaseTime">Unix timestamp of when the purchase occurred.</param>
/// <param name="purchaseToken">A token representing the purchase that may be used to cancel the subscription.</param>
/// <param name="signedRequest">Server-signed encoding of the purchase request.</param>
/// <param name="status">The status of the subscription, such as CANCELED.</param>
/// <param name="subscriptionTerm">The billing cycle of a subscription.</param>
internal Subscription(
long deactivationTime,
bool isEntitlementActive,
long periodStartTime,
long periodEndTime,
string productID,
string purchasePlatform,
IDictionary<string, object> purchasePrice,
long purchaseTime,
string purchaseToken,
string signedRequest,
string status,
string subscriptionTerm)
{
int deactivationTimeInt;
try {
deactivationTimeInt = Convert.ToInt32(deactivationTime);
} catch (OverflowException) {
throw new ArgumentException("purchaseTime");
}
int periodStartTimeInt;
try {
periodStartTimeInt = Convert.ToInt32(periodStartTime);
} catch (OverflowException) {
throw new ArgumentException("periodStartTime");
}
int periodEndTimeInt;
try {
periodEndTimeInt = Convert.ToInt32(periodEndTime);
} catch (OverflowException) {
throw new ArgumentException("periodEndTime");
}
if (string.IsNullOrEmpty(productID))
{
throw new ArgumentNullException("productID");
}
if (string.IsNullOrEmpty(purchasePlatform))
{
throw new ArgumentNullException("purchasePlatform");
}
int purchaseTimeInt;
try {
purchaseTimeInt = Convert.ToInt32(purchaseTime);
} catch (OverflowException) {
throw new ArgumentException("purchaseTime");
}
if (string.IsNullOrEmpty(purchaseToken))
{
throw new ArgumentNullException("purchaseToken");
}
if (string.IsNullOrEmpty(signedRequest))
{
throw new ArgumentNullException("signedRequest");
}
if (string.IsNullOrEmpty(status))
{
throw new ArgumentNullException("status");
}
if (string.IsNullOrEmpty(subscriptionTerm))
{
throw new ArgumentNullException("subscriptionTerm");
}
this.DeactivationTime = Utilities.FromTimestamp(deactivationTimeInt);
this.IsEntitlementActive = isEntitlementActive;
this.PeriodStartTime = Utilities.FromTimestamp(periodStartTimeInt);
this.PeriodEndTime = Utilities.FromTimestamp(periodEndTimeInt);
this.ProductID = productID;
this.PurchasePlatform = purchasePlatform;
this.PurchasePrice = new CurrencyAmount(purchasePrice["currency"].ToStringNullOk(), purchasePrice["amount"].ToStringNullOk());
this.PurchaseTime = Utilities.FromTimestamp(purchaseTimeInt);
this.PurchaseToken = purchaseToken;
this.SignedRequest = signedRequest;
this.Status = status;
this.SubscriptionTerm = subscriptionTerm;
}
/// <summary>
/// Gets the deactivation time.
/// </summary>
/// <value>The deactivation time.</value>
public DateTime DeactivationTime { get; private set; }
/// <summary>
/// Gets whether or not the entitlement is active.
/// </summary>
/// <value>The entitlement status.</value>
public bool IsEntitlementActive { get; private set; }
/// <summary>
/// Gets the period start time.
/// </summary>
/// <value>The period start time.</value>
public DateTime PeriodStartTime { get; private set; }
/// <summary>
/// Gets the period end time.
/// </summary>
/// <value>The period end time.</value>
public DateTime PeriodEndTime { get; private set; }
/// <summary>
/// Gets the product identifier.
/// </summary>
/// <value>The product identifier.</value>
public string ProductID { get; private set; }
/// <summary>
/// Gets the platform associated with the purchase.
/// </summary>
/// <value>The purchase platform, such as "GOOGLE" or "FB".</value>
public string PurchasePlatform { get; private set; }
/// <summary>
/// Gets the amount and currency fields associated with the purchase.
/// </summary>
/// <value>The amount and currency fields associated with the purchase as a CurrencyAmount</value>
public CurrencyAmount PurchasePrice { get; private set; }
/// <summary>
/// Gets the purchase time.
/// </summary>
/// <value>The purchase time.</value>
public DateTime PurchaseTime { get; private set; }
/// <summary>
/// Gets the purchase token.
/// </summary>
/// <value>The purchase token.</value>
public string PurchaseToken { get; private set; }
/// <summary>
/// Gets the price currency code.
/// </summary>
/// <value>The price currency code.</value>
public string SignedRequest { get; private set; }
/// <summary>
/// Gets the subscription status.
/// </summary>
/// <value>The subscription status</value>
public string Status { get; private set; }
/// <summary>
/// Gets the subscription term.
/// </summary>
/// <value>The subscription term</value>
public string SubscriptionTerm { get; private set; }
/// <summary>
/// Returns a <see cref="System.String"/> that represents a <see cref="Facebook.Unity.Subscription"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents a <see cref="Facebook.Unity.Subscription"/>.</returns>
public override string ToString()
{
return Utilities.FormatToString(
null,
this.GetType().Name,
new Dictionary<string, string>()
{
{ "DeactivationTime", this.DeactivationTime.TotalSeconds().ToString() },
{ "IsEntitlementActive", this.IsEntitlementActive.ToStringNullOk() },
{ "PeriodStartTime", this.PeriodStartTime.TotalSeconds().ToString() },
{ "PeriodEndTime", this.PeriodEndTime.TotalSeconds().ToString() },
{ "ProductID", this.ProductID },
{ "PurchasePlatform", this.PurchasePlatform },
{ "PurchasePrice", this.PurchasePrice.ToString() },
{ "PurchaseTime", this.PurchaseTime.TotalSeconds().ToString() },
{ "PurchaseToken", this.PurchaseToken },
{ "SignedRequest", this.SignedRequest },
{ "Status", this.Status },
{ "SubscriptionTerm", this.SubscriptionTerm },
});
}
}
}
| 234 |
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 UserAgeRange
{
internal UserAgeRange(long min, long max)
{
this.Min = min;
this.Max = max;
}
/// <summary>
/// Gets the user's minimun age, -1 if unspecified.
/// </summary>
/// <value>The user's minimun age</value>
public long Min { get; private set; }
/// <summary>
/// Gets the user's maximun age, -1 if unspecified.
/// </summary>
/// <value>The user's maximun age.</value>
public long Max { get; private set; }
internal static UserAgeRange AgeRangeFromDictionary(IDictionary<string, string> dictionary)
{
string minStr;
string maxStr;
long min;
long max;
dictionary.TryGetValue("ageMin", out minStr);
dictionary.TryGetValue("ageMax", out maxStr);
min = long.TryParse(minStr, out min) ? min : -1;
max = long.TryParse(maxStr, out max) ? max : -1;
if (min < 0 && max < 0)
{
return null;
}
return new UserAgeRange(min, max);
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.UserAgeRange"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="Facebook.Unity.UserAgeRange"/>.</returns>
public override string ToString()
{
return Utilities.FormatToString(
null,
this.GetType().Name,
new Dictionary<string, string>()
{
{ "Min", this.Min.ToString()},
{ "Max", this.Max.ToString()},
});
}
}
}
| 80 |
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.Canvas
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
internal sealed class CanvasFacebook : FacebookBase, ICanvasFacebookImplementation
{
internal const string MethodAppRequests = "apprequests";
internal const string MethodFeed = "feed";
internal const string MethodPay = "pay";
internal const string CancelledResponse = "{\"cancelled\":true}";
internal const string FacebookConnectURL = "https://connect.facebook.net";
private const string AuthResponseKey = "authResponse";
private string appId;
private string appLinkUrl;
private ICanvasJSWrapper canvasJSWrapper;
private HideUnityDelegate onHideUnityDelegate;
public CanvasFacebook(): this(GetCanvasJSWrapper(), new CallbackManager())
{
}
public CanvasFacebook(ICanvasJSWrapper canvasJSWrapper, CallbackManager callbackManager)
: base(callbackManager)
{
this.canvasJSWrapper = canvasJSWrapper;
}
private static ICanvasJSWrapper GetCanvasJSWrapper()
{
Assembly assembly = Assembly.Load("Facebook.Unity.Canvas");
Type type = assembly.GetType("Facebook.Unity.Canvas.CanvasJSWrapper");
ICanvasJSWrapper canvasJSWrapper = (ICanvasJSWrapper)Activator.CreateInstance(type);
return canvasJSWrapper;
}
public override bool LimitEventUsage { get; set; }
public override string SDKName
{
get
{
return "FBJSSDK";
}
}
public override string SDKVersion
{
get
{
return this.canvasJSWrapper.GetSDKVersion();
}
}
public override string SDKUserAgent
{
get
{
// We want to log whether we are running as webgl or in the web player.
string webPlatform;
switch (Constants.CurrentPlatform)
{
case FacebookUnityPlatform.WebGL:
webPlatform = string.Format(
CultureInfo.InvariantCulture,
"FBUnity{0}",
Constants.CurrentPlatform.ToString());
break;
default:
FacebookLogger.Warn("Currently running on uknown web platform");
webPlatform = "FBUnityWebUnknown";
break;
}
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1}",
base.SDKUserAgent,
Utilities.GetUserAgent(webPlatform, FacebookSdkVersion.Build));
}
}
public void Init(
string appId,
bool cookie,
bool logging,
bool status,
bool xfbml,
string channelUrl,
string authResponse,
bool frictionlessRequests,
string javascriptSDKLocale,
bool loadDebugJSSDK,
HideUnityDelegate hideUnityDelegate,
InitDelegate onInitComplete)
{
base.Init(onInitComplete);
this.canvasJSWrapper.InitScreenPosition();
this.appId = appId;
this.onHideUnityDelegate = hideUnityDelegate;
MethodArguments parameters = new MethodArguments();
parameters.AddString("appId", appId);
parameters.AddPrimative("cookie", cookie);
parameters.AddPrimative("logging", logging);
parameters.AddPrimative("status", status);
parameters.AddPrimative("xfbml", xfbml);
parameters.AddString("channelUrl", channelUrl);
parameters.AddString("authResponse", authResponse);
parameters.AddPrimative("frictionlessRequests", frictionlessRequests);
parameters.AddString("version", FB.GraphApiVersion);
// use 1/0 for booleans, otherwise you'll get strings "True"/"False"
this.canvasJSWrapper.Init(
FacebookConnectURL,
javascriptSDKLocale,
loadDebugJSSDK ? 1 : 0,
parameters.ToJsonString(),
status ? 1 : 0);
}
public override void LogInWithPublishPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
this.canvasJSWrapper.DisableFullScreen();
this.canvasJSWrapper.Login(permissions, CallbackManager.AddFacebookDelegate(callback));
}
public override void LogInWithReadPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
this.canvasJSWrapper.DisableFullScreen();
this.canvasJSWrapper.Login(permissions, CallbackManager.AddFacebookDelegate(callback));
}
public override void LogOut()
{
base.LogOut();
this.canvasJSWrapper.Logout();
}
public override 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)
{
this.ValidateAppRequestArgs(
message,
actionType,
objectId,
to,
filters,
excludeIds,
maxRecipients,
data,
title,
callback);
MethodArguments args = new MethodArguments();
args.AddString("message", message);
args.AddCommaSeparatedList("to", to);
args.AddString("action_type", actionType != null ? actionType.ToString() : null);
args.AddString("object_id", objectId);
args.AddList("filters", filters);
args.AddList("exclude_ids", excludeIds);
args.AddNullablePrimitive("max_recipients", maxRecipients);
args.AddString("data", data);
args.AddString("title", title);
var call = new CanvasUIMethodCall<IAppRequestResult>(this, MethodAppRequests, Constants.OnAppRequestsCompleteMethodName);
call.Callback = callback;
call.Call(args);
}
public override void ActivateApp(string appId)
{
this.canvasJSWrapper.ActivateApp();
}
public override void ShareLink(
Uri contentURL,
string contentTitle,
string contentDescription,
Uri photoURL,
FacebookDelegate<IShareResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddUri("link", contentURL);
args.AddString("name", contentTitle);
args.AddString("description", contentDescription);
args.AddUri("picture", photoURL);
var call = new CanvasUIMethodCall<IShareResult>(this, MethodFeed, Constants.OnShareCompleteMethodName);
call.Callback = callback;
call.Call(args);
}
public override void FeedShare(
string toId,
Uri link,
string linkName,
string linkCaption,
string linkDescription,
Uri picture,
string mediaSource,
FacebookDelegate<IShareResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("to", toId);
args.AddUri("link", link);
args.AddString("name", linkName);
args.AddString("caption", linkCaption);
args.AddString("description", linkDescription);
args.AddUri("picture", picture);
args.AddString("source", mediaSource);
var call = new CanvasUIMethodCall<IShareResult>(this, MethodFeed, Constants.OnShareCompleteMethodName);
call.Callback = callback;
call.Call(args);
}
public void Pay(
string product,
string action,
int quantity,
int? quantityMin,
int? quantityMax,
string requestId,
string pricepointId,
string testCurrency,
FacebookDelegate<IPayResult> callback)
{
this.PayImpl(
product,
/*productId*/ null,
action,
quantity,
quantityMin,
quantityMax,
requestId,
pricepointId,
testCurrency,
/*developerPayload*/ null,
callback);
}
public void PayWithProductId(
string productId,
string action,
int quantity,
int? quantityMin,
int? quantityMax,
string requestId,
string pricepointId,
string testCurrency,
FacebookDelegate<IPayResult> callback)
{
this.PayImpl(
/*product*/ null,
productId,
action,
quantity,
quantityMin,
quantityMax,
requestId,
pricepointId,
testCurrency,
/*developerPayload*/ null,
callback);
}
public void PayWithProductId(
string productId,
string action,
string developerPayload,
string testCurrency,
FacebookDelegate<IPayResult> callback)
{
this.PayImpl(
/*product*/ null,
productId,
action,
/*quantity*/ 1,
/*quantityMin*/ null,
/*quantityMax*/ null,
/*requestId*/ null,
/*pricepointId*/ null,
testCurrency,
developerPayload,
callback);
}
public override void GetAppLink(FacebookDelegate<IAppLinkResult> callback)
{
var result = new Dictionary<string, object>()
{
{
"url", this.appLinkUrl
}
};
callback(new AppLinkResult(new ResultContainer(result)));
this.appLinkUrl = string.Empty;
}
public override void AppEventsLogEvent(
string logEvent,
float? valueToSum,
Dictionary<string, object> parameters)
{
this.canvasJSWrapper.LogAppEvent(
logEvent,
valueToSum,
MiniJSON.Json.Serialize(parameters));
}
public override void AppEventsLogPurchase(
float purchaseAmount,
string currency,
Dictionary<string, object> parameters)
{
this.canvasJSWrapper.LogPurchase(
purchaseAmount,
currency,
MiniJSON.Json.Serialize(parameters));
}
public override void OnLoginComplete(ResultContainer result)
{
CanvasFacebook.FormatAuthResponse(
result,
(formattedResponse) =>
{
this.OnAuthResponse(new LoginResult(formattedResponse));
});
}
public override void OnGetAppLinkComplete(ResultContainer message)
{
// We should never get here on canvas. We store the app link on this object
// so should never hit this method.
throw new NotImplementedException();
}
// used only to refresh the access token
public void OnFacebookAuthResponseChange(string responseJsonData)
{
this.OnFacebookAuthResponseChange(new ResultContainer(responseJsonData));
}
public void OnFacebookAuthResponseChange(ResultContainer resultContainer)
{
CanvasFacebook.FormatAuthResponse(
resultContainer,
(formattedResponse) =>
{
var result = new LoginResult(formattedResponse);
AccessToken.CurrentAccessToken = result.AccessToken;
});
}
public void OnPayComplete(string responseJsonData)
{
this.OnPayComplete(new ResultContainer(responseJsonData));
}
public void OnPayComplete(ResultContainer resultContainer)
{
var result = new PayResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void OnAppRequestsComplete(ResultContainer resultContainer)
{
var result = new AppRequestResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void OnShareLinkComplete(ResultContainer resultContainer)
{
var result = new ShareResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnUrlResponse(string url)
{
this.appLinkUrl = url;
}
public void OnHideUnity(bool isGameShown)
{
if (this.onHideUnityDelegate != null)
{
this.onHideUnityDelegate(isGameShown);
}
}
private static void FormatAuthResponse(ResultContainer result, Utilities.Callback<ResultContainer> callback)
{
if (result.ResultDictionary == null)
{
callback(result);
return;
}
IDictionary<string, object> authResponse;
if (result.ResultDictionary.TryGetValue(CanvasFacebook.AuthResponseKey, out authResponse))
{
result.ResultDictionary.Remove(CanvasFacebook.AuthResponseKey);
foreach (var item in authResponse)
{
result.ResultDictionary[item.Key] = item.Value;
}
}
// The JS SDK doesn't always store the permissions so request them before returning the results
if (result.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey)
&& !result.ResultDictionary.ContainsKey(LoginResult.PermissionsKey))
{
var parameters = new Dictionary<string, string>()
{
{ "fields", "permissions" },
{ Constants.AccessTokenKey, (string)result.ResultDictionary[LoginResult.AccessTokenKey] },
};
FacebookDelegate<IGraphResult> apiCallback = (IGraphResult r) =>
{
IDictionary<string, object> permissionsJson;
if (r.ResultDictionary != null && r.ResultDictionary.TryGetValue("permissions", out permissionsJson))
{
IList<string> permissions = new List<string>();
IList<object> data;
if (permissionsJson.TryGetValue("data", out data))
{
foreach (var permission in data)
{
var permissionDictionary = permission as IDictionary<string, object>;
if (permissionDictionary != null)
{
string status;
if (permissionDictionary.TryGetValue("status", out status)
&& status.Equals("granted", StringComparison.InvariantCultureIgnoreCase))
{
string permissionName;
if (permissionDictionary.TryGetValue("permission", out permissionName))
{
permissions.Add(permissionName);
}
else
{
FacebookLogger.Warn("Didn't find permission name");
}
}
else
{
FacebookLogger.Warn("Didn't find status in permissions result");
}
}
else
{
FacebookLogger.Warn("Failed to case permission dictionary");
}
}
}
else
{
FacebookLogger.Warn("Failed to extract data from permissions");
}
result.ResultDictionary[LoginResult.PermissionsKey] = permissions.ToCommaSeparateList();
}
else
{
FacebookLogger.Warn("Failed to load permissions for access token");
}
callback(result);
};
FB.API(
"me",
HttpMethod.GET,
apiCallback,
parameters);
}
else
{
callback(result);
}
}
private void PayImpl(
string product,
string productId,
string action,
int quantity,
int? quantityMin,
int? quantityMax,
string requestId,
string pricepointId,
string testCurrency,
string developerPayload,
FacebookDelegate<IPayResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("product", product);
args.AddString("product_id", productId);
args.AddString("action", action);
args.AddPrimative("quantity", quantity);
args.AddNullablePrimitive("quantity_min", quantityMin);
args.AddNullablePrimitive("quantity_max", quantityMax);
args.AddString("request_id", requestId);
args.AddString("pricepoint_id", pricepointId);
args.AddString("test_currency", testCurrency);
args.AddString("developer_payload", developerPayload);
var call = new CanvasUIMethodCall<IPayResult>(this, MethodPay, Constants.OnPayCompleteMethodName);
call.Callback = callback;
call.Call(args);
}
private class CanvasUIMethodCall<T> : MethodCall<T> where T : IResult
{
private CanvasFacebook canvasImpl;
private string callbackMethod;
public CanvasUIMethodCall(CanvasFacebook canvasImpl, string methodName, string callbackMethod)
: base(canvasImpl, methodName)
{
this.canvasImpl = canvasImpl;
this.callbackMethod = callbackMethod;
}
public override void Call(MethodArguments args)
{
this.UI(this.MethodName, args, this.Callback);
}
private void UI(
string method,
MethodArguments args,
FacebookDelegate<T> callback = null)
{
this.canvasImpl.canvasJSWrapper.DisableFullScreen();
var clonedArgs = new MethodArguments(args);
clonedArgs.AddString("app_id", this.canvasImpl.appId);
clonedArgs.AddString("method", method);
var uniqueId = this.canvasImpl.CallbackManager.AddFacebookDelegate(callback);
this.canvasImpl.canvasJSWrapper.Ui(clonedArgs.ToJsonString (), uniqueId, this.callbackMethod);
}
}
public override void GetCatalog(FacebookDelegate<ICatalogResult> callback)
{
throw new NotImplementedException();
}
public override void GetPurchases(FacebookDelegate<IPurchasesResult> callback)
{
throw new NotImplementedException();
}
public override void Purchase(string productID, FacebookDelegate<IPurchaseResult> callback, string developerPayload = "")
{
throw new NotImplementedException();
}
public override void ConsumePurchase(string productToken, FacebookDelegate<IConsumePurchaseResult> callback)
{
throw new NotImplementedException();
}
public override void GetSubscribableCatalog(FacebookDelegate<ISubscribableCatalogResult> callback)
{
throw new NotImplementedException();
}
public override void GetSubscriptions(FacebookDelegate<ISubscriptionsResult> callback)
{
throw new NotImplementedException();
}
public override void PurchaseSubscription(string productID, FacebookDelegate<ISubscriptionResult> callback)
{
throw new NotImplementedException();
}
public override void CancelSubscription(string productToken, FacebookDelegate<ICancelSubscriptionResult> callback)
{
throw new NotImplementedException();
}
public override Profile CurrentProfile()
{
throw new NotImplementedException();
}
public override void CurrentProfile(FacebookDelegate<IProfileResult> callback)
{
throw new NotSupportedException();
}
public override void LoadInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback)
{
throw new NotImplementedException();
}
public override void ShowInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback)
{
throw new NotImplementedException();
}
public override void LoadRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback)
{
throw new NotImplementedException();
}
public override void ShowRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback)
{
throw new NotImplementedException();
}
public override void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback)
{
throw new NotImplementedException();
}
public override void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void ScheduleAppToUserNotification(string title, string body, Uri media, int timeInterval, string payload, FacebookDelegate<IScheduleAppToUserNotificationResult> callback)
{
throw new NotImplementedException();
}
public override void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback)
{
throw new NotImplementedException();
}
public override void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback)
{
throw new NotImplementedException();
}
public override void GetTournament(FacebookDelegate<ITournamentResult> callback)
{
throw new NotImplementedException();
}
public override void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback)
{
throw new NotImplementedException();
}
public override void CreateTournament(int initialScore, string title, string imageBase64DataUrl, string sortOrder, string scoreFormat, Dictionary<string, string> data, FacebookDelegate<ITournamentResult> callback)
{
throw new NotImplementedException();
}
public override void UploadImageToMediaLibrary(string caption, Uri imageUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback)
{
throw new NotImplementedException();
}
public override void UploadVideoToMediaLibrary(string caption, Uri videoUri, bool shouldLaunchMediaDialog, FacebookDelegate<IMediaUploadResult> callback)
{
throw new NotImplementedException();
}
public override void GetUserLocale(FacebookDelegate<ILocaleResult> callback)
{
throw new NotImplementedException();
}
}
}
| 715 |
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.Canvas
{
using UnityEngine;
internal class CanvasFacebookGameObject : FacebookGameObject, ICanvasFacebookCallbackHandler
{
protected ICanvasFacebookImplementation CanvasFacebookImpl
{
get
{
return (ICanvasFacebookImplementation)this.Facebook;
}
}
public void OnPayComplete(string result)
{
this.CanvasFacebookImpl.OnPayComplete(new ResultContainer(result));
}
public void OnFacebookAuthResponseChange(string message)
{
this.CanvasFacebookImpl.OnFacebookAuthResponseChange(new ResultContainer(message));
}
public void OnUrlResponse(string message)
{
this.CanvasFacebookImpl.OnUrlResponse(message);
}
public void OnHideUnity(bool hide)
{
this.CanvasFacebookImpl.OnHideUnity(hide);
}
protected override void OnAwake()
{
// Facebook JS Bridge lives in it's own gameobject for optimization reasons
// see UnityObject.SendMessage()
var bridgeObject = new GameObject("FacebookJsBridge");
bridgeObject.AddComponent<JsBridge>();
bridgeObject.transform.parent = gameObject.transform;
}
}
}
| 65 |
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.Canvas
{
internal class CanvasFacebookLoader : FB.CompiledFacebookLoader
{
protected override FacebookGameObject FBGameObject
{
get
{
CanvasFacebookGameObject canvasFB = ComponentFactory.GetComponent<CanvasFacebookGameObject>();
if (canvasFB.Facebook == null)
{
canvasFB.Facebook = new CanvasFacebook();
}
return canvasFB;
}
}
}
}
| 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.Canvas
{
internal interface ICanvasFacebook : IPayFacebook, IFacebook
{
}
}
| 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.Canvas
{
internal interface ICanvasFacebookCallbackHandler : IFacebookCallbackHandler
{
void OnPayComplete(string message);
// Called when the JSSDK event authResponseChange is fired when a user logins in
// Using something such as a login button from the JSSDK.
void OnFacebookAuthResponseChange(string message);
// Used for deeplinking
void OnUrlResponse(string message);
void OnHideUnity(bool hide);
}
}
| 37 |
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.Canvas
{
internal interface ICanvasFacebookImplementation : ICanvasFacebook, ICanvasFacebookResultHandler
{
}
}
| 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.Canvas
{
using System;
using Facebook.Unity;
internal interface ICanvasFacebookResultHandler : IFacebookResultHandler
{
void OnPayComplete(ResultContainer resultContainer);
void OnFacebookAuthResponseChange(ResultContainer resultContainer);
// Used for deeplinking
void OnUrlResponse(string message);
void OnHideUnity(bool hide);
}
}
| 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.Canvas
{
using System.Collections.Generic;
internal interface ICanvasJSWrapper
{
string GetSDKVersion();
void DisableFullScreen();
void Init(string connectFacebookUrl, string locale, int debug, string initParams, int status);
void Login(IEnumerable<string> scope, string callback_id);
void Logout();
void ActivateApp();
void LogAppEvent(string eventName, float? valueToSum, string parameters);
void LogPurchase(float purchaseAmount, string currency, string parameters);
void Ui(string x, string uid, string callbackMethodName);
void InitScreenPosition();
}
}
| 48 |
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.Canvas
{
using UnityEngine;
internal class JsBridge : MonoBehaviour
{
private ICanvasFacebookCallbackHandler facebook;
public void Start()
{
this.facebook = ComponentFactory.GetComponent<CanvasFacebookGameObject>(
ComponentFactory.IfNotExist.ReturnNull);
}
public void OnLoginComplete(string responseJsonData = "")
{
this.facebook.OnLoginComplete(responseJsonData);
}
public void OnFacebookAuthResponseChange(string responseJsonData = "")
{
this.facebook.OnFacebookAuthResponseChange(responseJsonData);
}
public void OnPayComplete(string responseJsonData = "")
{
this.facebook.OnPayComplete(responseJsonData);
}
public void OnAppRequestsComplete(string responseJsonData = "")
{
this.facebook.OnAppRequestsComplete(responseJsonData);
}
public void OnShareLinkComplete(string responseJsonData = "")
{
this.facebook.OnShareLinkComplete(responseJsonData);
}
public void OnFacebookFocus(string state)
{
this.facebook.OnHideUnity(state != "hide");
}
public void OnInitComplete(string responseJsonData = "")
{
this.facebook.OnInitComplete(responseJsonData);
}
public void OnUrlResponse(string url = "")
{
this.facebook.OnUrlResponse(url);
}
}
}
| 76 |
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.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System;
using System.Text;
using UnityEngine.SceneManagement;
using System.Runtime.InteropServices;
namespace Facebook.Unity
{
public class CodelessCrawler : MonoBehaviour
{
#if UNITY_IOS
[DllImport ("__Internal")]
private static extern void IOSFBSendViewHierarchy (string tree);
#endif
private static bool isGeneratingSnapshot = false;
private static Camera mainCamera = null;
public void Awake ()
{
SceneManager.activeSceneChanged += onActiveSceneChanged;
}
public void CaptureViewHierarchy (string message)
{
if (null == mainCamera || !mainCamera.isActiveAndEnabled) {
updateMainCamera ();
}
StartCoroutine (GenSnapshot ());
}
private IEnumerator GenSnapshot ()
{
yield return (new WaitForEndOfFrame ());
if (isGeneratingSnapshot) {
yield break;
}
isGeneratingSnapshot = true;
StringBuilder masterBuilder = new StringBuilder ();
masterBuilder.AppendFormat (
@"{{""screenshot"":""{0}"",",
GenBase64Screenshot ()
);
masterBuilder.AppendFormat (
@"""screenname"":""{0}"",",
SceneManager.GetActiveScene ().name
);
masterBuilder.AppendFormat (
@"""view"":[{0}]}}",
GenViewJson ()
);
string json = masterBuilder.ToString ();
switch (Constants.CurrentPlatform) {
case FacebookUnityPlatform.Android:
SendAndroid (json);
break;
case FacebookUnityPlatform.IOS:
SendIos (json);
break;
default:
break;
}
isGeneratingSnapshot = false;
}
private static void SendAndroid (string json)
{
using (AndroidJavaObject viewIndexer = new AndroidJavaClass ("com.facebook.appevents.codeless.ViewIndexer")) {
viewIndexer.CallStatic ("sendToServerUnityInstance", json);
}
}
private static void SendIos (string json)
{
#if UNITY_IOS
CodelessCrawler.IOSFBSendViewHierarchy (json);
#endif
}
private static string GenBase64Screenshot ()
{
Texture2D tex = new Texture2D (Screen.width, Screen.height);
tex.ReadPixels (new Rect (0, 0, Screen.width, Screen.height), 0, 0);
tex.Apply ();
string screenshot64 = System.Convert.ToBase64String (tex.EncodeToJPG ());
UnityEngine.Object.Destroy (tex);
return screenshot64;
}
private static string GenViewJson ()
{
GameObject[] rootGameObjs = UnityEngine.SceneManagement.SceneManager.GetActiveScene ().GetRootGameObjects ();
StringBuilder builder = new StringBuilder ();
builder.AppendFormat (
@"{{""classname"":""{0}"",""childviews"":[",
SceneManager.GetActiveScene ().name
);
foreach (GameObject curObj in rootGameObjs) {
GenChild (curObj, builder);
builder.Append (",");
}
if (builder [builder.Length - 1] == ',') {
builder.Length--;
}
builder.AppendFormat (
@"],""classtypebitmask"":""{0}"",""tag"":""0"",""dimension"":{{""height"":{1},""width"":{2},""scrolly"":{3},""left"":{4},""top"":{5},""scrollx"":{6},""visibility"":{7}}}}}",
"0",
(int)Screen.height,
(int)Screen.width,
"0",
"0",
"0",
"0",
"0"
);
return builder.ToString ();
}
private static void GenChild (GameObject curObj, StringBuilder builder)
{
builder.AppendFormat (
@"{{""classname"":""{0}"",""childviews"":[",
curObj.name
);
int childCount = curObj.transform.childCount;
for (int i = 0; i < childCount; i++) {
if (null == curObj.GetComponent<Button> ()) {
GenChild (curObj.transform.GetChild (i).gameObject, builder);
builder.Append (",");
}
}
if (builder [builder.Length - 1] == ',') {
builder.Length--;
}
UnityEngine.Canvas canvasParent = curObj.GetComponentInParent<UnityEngine.Canvas> ();
string btntext = "";
if (null != curObj.GetComponent<Button> () && null != canvasParent) {
Rect rect = curObj.GetComponent<RectTransform> ().rect;
Vector2 position = getScreenCoordinate (curObj.transform.position, canvasParent.renderMode);
Text textComponent = curObj.GetComponent<Button> ().GetComponentInChildren<Text> ();
if (null != textComponent) {
btntext = "\"text\":\"" + textComponent.text + "\",";
}
builder.AppendFormat (
@"],{8}""classtypebitmask"":""{0}"",""tag"":""0"",""dimension"":{{""height"":{1},""width"":{2},""scrolly"":{3},""left"":{4},""top"":{5},""scrollx"":{6},""visibility"":{7}}}}}",
getClasstypeBitmaskButton (),
(int)rect.height,
(int)rect.width,
0,
(int)Math.Ceiling (position.x - (rect.width / 2)),//left
(int)Math.Ceiling ((Screen.height - position.y - (rect.height / 2))),
0,
getVisibility (curObj),
btntext
);
} else {
builder.AppendFormat (
@"],{8}""classtypebitmask"":""{0}"",""tag"":""0"",""dimension"":{{""height"":{1},""width"":{2},""scrolly"":{3},""left"":{4},""top"":{5},""scrollx"":{6},""visibility"":{7}}}}}",
getClasstypeBitmaskButton (),
0,
0,
0,
0,
0,
0,
getVisibility (curObj),
btntext
);
}
}
private void onActiveSceneChanged (Scene arg0, Scene arg1)
{
updateMainCamera ();
}
private static void updateMainCamera ()
{
mainCamera = Camera.main;
}
private static Vector2 getScreenCoordinate (Vector3 position, RenderMode renderMode)
{
if (RenderMode.ScreenSpaceOverlay == renderMode || null == mainCamera) {
return(position);
} else {
return mainCamera.WorldToScreenPoint (position);
}
}
private static string getClasstypeBitmaskButton ()
{
switch (Constants.CurrentPlatform) {
case FacebookUnityPlatform.Android:
return "4";
case FacebookUnityPlatform.IOS:
return "16";
default:
return "0";
}
}
private static string getVisibility (GameObject gameObj)
{
if (gameObj.activeInHierarchy) {
return "0";
} else {
return "8";
}
}
}
}
| 242 |
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;
using System.Collections.Generic;
using UnityEngine;
namespace Facebook.Unity
{
public class CodelessUIInteractEvent : MonoBehaviour
{
private FBSDKEventBindingManager eventBindingManager { get; set; }
void Awake ()
{
switch (Constants.CurrentPlatform) {
case FacebookUnityPlatform.Android:
SetLoggerInitAndroid ();
break;
case FacebookUnityPlatform.IOS:
SetLoggerInitIos ();
break;
default:
break;
}
}
private static void SetLoggerInitAndroid ()
{
AndroidJavaObject fetchedAppSettingsManager = new AndroidJavaClass ("com.facebook.internal.FetchedAppSettingsManager");
fetchedAppSettingsManager.CallStatic ("setIsUnityInit", true);
}
private static void SetLoggerInitIos ()
{
//PLACEHOLDER for IOS
}
public void OnReceiveMapping (string message)
{
var dict = MiniJSON.Json.Deserialize(message) as List<System.Object>;
this.eventBindingManager = new FBSDKEventBindingManager(dict);
}
}
}
| 65 |
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;
namespace Facebook.Unity
{
public class FBSDKCodelessPathComponent
{
public FBSDKCodelessPathComponent (Dictionary<string, object> dict)
{
className = (string) dict[Constants.EventBindingKeysClassName];
if (className != null) {
this.className = className;
}
if (dict.ContainsKey(Constants.EventBindingKeysText)) {
text = (string) dict[Constants.EventBindingKeysText];
}
if (dict.ContainsKey(Constants.EventBindingKeysHint)) {
this.hint = (string) dict[Constants.EventBindingKeysHint];
}
if (dict.ContainsKey(Constants.EventBindingKeysDescription)) {
desc = (string) dict[Constants.EventBindingKeysDescription];
}
if (dict.ContainsKey(Constants.EventBindingKeysIndex)) {
this.index = (long) dict[Constants.EventBindingKeysIndex];
}
if (dict.ContainsKey(Constants.EventBindingKeysTag)) {
this.tag = (string) dict[Constants.EventBindingKeysTag];
}
if (dict.ContainsKey(Constants.EventBindingKeysSection)) {
section = (long) dict[Constants.EventBindingKeysSection];
}
if (dict.ContainsKey(Constants.EventBindingKeysRow)) {
row = (long) dict[Constants.EventBindingKeysRow];
}
if (dict.ContainsKey(Constants.EventBindingKeysMatchBitmask)) {
matchBitmask = (long) dict[Constants.EventBindingKeysMatchBitmask];
}
}
public string className {get; set;}
public string text {get; set;}
public string hint {get; set;}
public string desc {get; set;}
public string tag {get; set;}
public long index {get; set;}
public long section {get; set;}
public long row {get; set;}
public long matchBitmask {get; set;}
}
}
| 80 |
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;
namespace Facebook.Unity
{
public class FBSDKEventBinding
{
public FBSDKEventBinding (Dictionary<string, object> dict)
{
eventName = (string) dict[Constants.EventBindingKeysEventName];
if (eventName != null) {
this.eventName = eventName;
}
eventType = (string) dict[Constants.EventBindingKeysEventType];
if (eventType != null) {
this.eventType = eventType;
}
appVersion = (string) dict[Constants.EventBindingKeysAppVersion];
if (appVersion != null) {
this.appVersion = appVersion;
}
eventName = (string) dict[Constants.EventBindingKeysEventName];
if (eventName != null) {
this.eventName = eventName;
}
var _path = (List<System.Object>) dict[Constants.EventBindingKeysPath];
path = new List<FBSDKCodelessPathComponent> ();
foreach(Dictionary<string, System.Object> p in _path) {
var pathComponent = new FBSDKCodelessPathComponent(p);
path.Add(pathComponent);
}
}
public string eventName {get; set;}
public string eventType {get; set;}
public string appVersion {get; set;}
public string pathType {get; set;}
public List<FBSDKCodelessPathComponent> path {get; set;}
public List<string> parameters {get; set;}
}
}
| 66 |
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;
namespace Facebook.Unity
{
public class FBSDKEventBindingManager
{
public List<FBSDKEventBinding> eventBindings {get; set;}
public FBSDKEventBindingManager(List<System.Object> listDict)
{
this.eventBindings = new List<FBSDKEventBinding>();
foreach (Dictionary<string, object> dict in listDict) {
this.eventBindings.Add( new FBSDKEventBinding(dict));
}
}
}
}
| 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.
*/
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Facebook.Unity
{
public class FBSDKViewHiearchy
{
public static bool CheckGameObjectMatchPath(GameObject go, List<FBSDKCodelessPathComponent> path)
{
var goPath = GetPath (go);
return CheckPathMatchPath (goPath, path);
}
public static bool CheckPathMatchPath(List<FBSDKCodelessPathComponent> goPath, List<FBSDKCodelessPathComponent> path)
{
for (int i = 0; i < System.Math.Min(goPath.Count, path.Count); i++) {
var idxGoPath = goPath.Count - i - 1;
var idxPath = path.Count - i - 1;
var goPathComponent = goPath [idxGoPath];
var pathComponent = path [idxPath];
// TODO: add more attributes comparison beyond class names
if (String.Compare (goPathComponent.className, pathComponent.className) != 0) {
return false;
}
}
return true;
}
public static List<FBSDKCodelessPathComponent> GetPath(GameObject go)
{
return GetPath (go, Constants.MaxPathDepth);
}
public static List<FBSDKCodelessPathComponent> GetPath(GameObject go, int limit)
{
if (go == null || limit <= 0) {
return null;
}
var path = new List<FBSDKCodelessPathComponent> ();
var parent = GetParent (go);
if (parent != null) {
var parentPath = GetPath (parent, limit - 1);
path = parentPath;
} else {
// pAdd the scene first
var componentInfo1 = new Dictionary<string, System.Object>();
componentInfo1.Add (Constants.EventBindingKeysClassName, SceneManager.GetActiveScene ().name);
var pathComponent1 = new FBSDKCodelessPathComponent (componentInfo1);
path.Add (pathComponent1);
}
var componentInfo = GetAttribute(go, parent);
var pathComponent = new FBSDKCodelessPathComponent (componentInfo);
path.Add (pathComponent);
return path;
}
public static GameObject GetParent(GameObject go)
{
var parentTransform = go.transform.parent;
if (parentTransform != null) {
return parentTransform.gameObject;
}
return null;
}
public static Dictionary<string, System.Object> GetAttribute(GameObject obj, GameObject parent)
{
var result = new Dictionary<string, System.Object> ();
result.Add (Constants.EventBindingKeysClassName, obj.name);
if (parent != null) {
result.Add (Constants.EventBindingKeysIndex, Convert.ToInt64(obj.transform.GetSiblingIndex ()));
} else {
result.Add (Constants.EventBindingKeysIndex, Convert.ToInt64(0));
}
return result;
}
}
}
| 106 |
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.Mobile
{
using System;
using System.Collections.Generic;
internal interface IMobileFacebook : IFacebook
{
ShareDialogMode ShareDialogMode { get; set; }
string UserID { get; set; }
void EnableProfileUpdatesOnAccessTokenChange(bool enable);
void LoginWithTrackingPreference(string tracking, IEnumerable<string> permissions, string nonce,
FacebookDelegate<ILoginResult> callback);
void FetchDeferredAppLink(
FacebookDelegate<IAppLinkResult> callback);
void RefreshCurrentAccessToken(
FacebookDelegate<IAccessTokenRefreshResult> callback);
bool IsImplicitPurchaseLoggingEnabled();
void SetPushNotificationsDeviceTokenString(string token);
void SetAutoLogAppEventsEnabled(bool autoLogAppEventsEnabled);
void SetAdvertiserIDCollectionEnabled(bool advertiserIDCollectionEnabled);
bool SetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled);
void SetDataProcessingOptions(IEnumerable<string> options, int country, int state);
void OnIAPReady(FacebookDelegate<IIAPReadyResult> callback);
void InitCloudGame(FacebookDelegate<IInitCloudGameResult> callback);
void GameLoadComplete(FacebookDelegate<IGameLoadCompleteResult> callback);
void GetPayload(FacebookDelegate<IPayloadResult> callback);
void GetTournaments(FacebookDelegate<IGetTournamentsResult> callback);
void UpdateTournament(string tournamentID, int score, FacebookDelegate<ITournamentScoreResult> callback);
void UpdateAndShareTournament(string tournamentID, int score, FacebookDelegate<IDialogResult> callback);
void CreateAndShareTournament(
int initialScore,
string title,
TournamentSortOrder sortOrder,
TournamentScoreFormat scoreFormat,
long endTime,
string payload,
FacebookDelegate<IDialogResult> callback);
void OpenAppStore(FacebookDelegate<IOpenAppStoreResult> callback);
void CreateGamingContext(string playerID, FacebookDelegate<ICreateGamingContextResult> callback);
void SwitchGamingContext(string gamingContextID, FacebookDelegate<ISwitchGamingContextResult> callback);
void ChooseGamingContext(List<string> filters, int minSize, int maxSize, FacebookDelegate<IChooseGamingContextResult> callback);
void GetCurrentGamingContext(FacebookDelegate<IGetCurrentGamingContextResult> callback);
AuthenticationToken CurrentAuthenticationToken();
}
}
| 92 |
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.Mobile
{
internal interface IMobileFacebookCallbackHandler : IFacebookCallbackHandler
{
void OnFetchDeferredAppLinkComplete(string message);
void OnRefreshCurrentAccessTokenComplete(string message);
void OnFriendFinderComplete(string message);
void OnUploadImageToMediaLibraryComplete(string message);
void OnUploadVideoToMediaLibraryComplete(string message);
void OnOnIAPReadyComplete(string message);
void OnGetCatalogComplete(string message);
void OnGetPurchasesComplete(string message);
void OnPurchaseComplete(string message);
void OnConsumePurchaseComplete(string message);
void OnGetSubscribableCatalogComplete(string message);
void OnGetSubscriptionsComplete(string message);
void OnPurchaseSubscriptionComplete(string message);
void OnCancelSubscriptionComplete(string message);
void OnInitCloudGameComplete(string message);
void OnGameLoadCompleteComplete(string message);
void OnScheduleAppToUserNotificationComplete(string message);
void OnLoadInterstitialAdComplete(string message);
void OnShowInterstitialAdComplete(string message);
void OnLoadRewardedVideoComplete(string message);
void OnShowRewardedVideoComplete(string message);
void OnGetPayloadComplete(string message);
void OnPostSessionScoreComplete(string message);
void OnGetTournamentComplete(string message);
void OnShareTournamentComplete(string message);
void OnCreateTournamentComplete(string message);
void OnPostTournamentScoreComplete(string message);
void OnGetTournamentsComplete(string message);
void OnUpdateTournamentComplete(string message);
void OnTournamentDialogSuccess(string message);
void OnTournamentDialogCancel(string message);
void OnTournamentDialogError(string message);
void OnOpenAppStoreComplete(string message);
void OnCreateGamingContextComplete(string message);
void OnSwitchGamingContextComplete(string message);
void OnChooseGamingContextComplete(string message);
void OnGetCurrentGamingContextComplete(string message);
}
}
| 100 |
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.Mobile
{
internal interface IMobileFacebookImplementation : IMobileFacebook, IMobileFacebookResultHandler
{
}
}
| 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.Mobile
{
internal interface IMobileFacebookResultHandler : IFacebookResultHandler
{
void OnFetchDeferredAppLinkComplete(ResultContainer resultContainer);
void OnRefreshCurrentAccessTokenComplete(ResultContainer resultContainer);
void OnFriendFinderComplete(ResultContainer resultContainer);
void OnUploadImageToMediaLibraryComplete(ResultContainer resultContainer);
void OnUploadVideoToMediaLibraryComplete(ResultContainer resultContainer);
void OnOnIAPReadyComplete(ResultContainer resultContainer);
void OnGetCatalogComplete(ResultContainer resultContainer);
void OnGetPurchasesComplete(ResultContainer resultContainer);
void OnPurchaseComplete(ResultContainer resultContainer);
void OnConsumePurchaseComplete(ResultContainer resultContainer);
void OnGetSubscribableCatalogComplete(ResultContainer resultContainer);
void OnGetSubscriptionsComplete(ResultContainer resultContainer);
void OnPurchaseSubscriptionComplete(ResultContainer resultContainer);
void OnCancelSubscriptionComplete(ResultContainer resultContainer);
void OnInitCloudGameComplete(ResultContainer resultContainer);
void OnGameLoadCompleteComplete(ResultContainer resultContainer);
void OnScheduleAppToUserNotificationComplete(ResultContainer resultContainer);
void OnLoadInterstitialAdComplete(ResultContainer resultContainer);
void OnShowInterstitialAdComplete(ResultContainer resultContainer);
void OnLoadRewardedVideoComplete(ResultContainer resultContainer);
void OnShowRewardedVideoComplete(ResultContainer resultContainer);
void OnGetPayloadComplete(ResultContainer resultContainer);
void OnPostSessionScoreComplete(ResultContainer resultContainer);
void OnGetTournamentComplete(ResultContainer resultContainer);
void OnShareTournamentComplete(ResultContainer resultContainer);
void OnCreateTournamentComplete(ResultContainer resultContainer);
void OnPostTournamentScoreComplete(ResultContainer resultContainer);
void OnGetTournamentsComplete(ResultContainer resultContainer);
void OnUpdateTournamentComplete(ResultContainer resultContainer);
void OnTournamentDialogSuccess(ResultContainer resultContainer);
void OnTournamentDialogCancel(ResultContainer resultContainer);
void OnTournamentDialogError(ResultContainer resultContainer);
void OnOpenAppStoreComplete(ResultContainer resultContainer);
void OnCreateGamingContextComplete(ResultContainer resultContainer);
void OnSwitchGamingContextComplete(ResultContainer resultContainer);
void OnChooseGamingContextComplete(ResultContainer resultContainer);
void OnGetCurrentGamingContextComplete(ResultContainer resultContainer);
}
}
| 100 |
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.Mobile
{
using System;
using System.Collections.Generic;
/// <summary>
/// Classes defined on the mobile sdks.
/// </summary>
internal abstract class MobileFacebook : FacebookBase, IMobileFacebookImplementation
{
private const string CallbackIdKey = "callback_id";
private ShareDialogMode shareDialogMode = ShareDialogMode.AUTOMATIC;
protected MobileFacebook(CallbackManager callbackManager) : base(callbackManager)
{
}
/// <summary>
/// Gets or sets the dialog mode.
/// </summary>
/// <value>The dialog mode use for sharing, login, and other dialogs.</value>
public ShareDialogMode ShareDialogMode
{
get
{
return this.shareDialogMode;
}
set
{
this.shareDialogMode = value;
this.SetShareDialogMode(this.shareDialogMode);
}
}
public abstract string UserID { get; set; }
public abstract AuthenticationToken CurrentAuthenticationToken();
public override Profile CurrentProfile()
{
throw new NotImplementedException();
}
public override void CurrentProfile(FacebookDelegate<IProfileResult> callback)
{
throw new NotImplementedException();
}
public abstract void SetDataProcessingOptions(IEnumerable<string> options, int country, int state);
public abstract void EnableProfileUpdatesOnAccessTokenChange(bool enable);
public abstract void LoginWithTrackingPreference(
string tracking,
IEnumerable<string> permissions,
string nonce,
FacebookDelegate<ILoginResult> callback);
public abstract void FetchDeferredAppLink(
FacebookDelegate<IAppLinkResult> callback);
public abstract void RefreshCurrentAccessToken(
FacebookDelegate<IAccessTokenRefreshResult> callback);
public abstract bool IsImplicitPurchaseLoggingEnabled();
public abstract void SetAutoLogAppEventsEnabled (bool autoLogAppEventsEnabled);
public abstract void SetAdvertiserIDCollectionEnabled(bool advertiserIDCollectionEnabled);
public abstract bool SetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled);
public abstract void SetPushNotificationsDeviceTokenString(string token);
public override void OnLoginComplete(ResultContainer resultContainer)
{
var result = new LoginResult(resultContainer);
this.OnAuthResponse(result);
}
public override void OnGetAppLinkComplete(ResultContainer resultContainer)
{
var result = new AppLinkResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void OnAppRequestsComplete(ResultContainer resultContainer)
{
var result = new AppRequestResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnFetchDeferredAppLinkComplete(ResultContainer resultContainer)
{
var result = new AppLinkResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void OnShareLinkComplete(ResultContainer resultContainer)
{
var result = new ShareResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnRefreshCurrentAccessTokenComplete(ResultContainer resultContainer)
{
var result = new AccessTokenRefreshResult(resultContainer);
if (result.AccessToken != null)
{
AccessToken.CurrentAccessToken = result.AccessToken;
}
CallbackManager.OnFacebookResponse(result);
}
public override void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback)
{
throw new NotImplementedException();
}
public override void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public void OnFriendFinderComplete(ResultContainer resultContainer)
{
var result = new GamingServicesFriendFinderResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnUploadImageToMediaLibraryComplete(ResultContainer resultContainer)
{
var result = new MediaUploadResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnUploadVideoToMediaLibraryComplete(ResultContainer resultContainer)
{
var result = new MediaUploadResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnOnIAPReadyComplete(ResultContainer resultContainer)
{
var result = new IAPReadyResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetCatalogComplete(ResultContainer resultContainer)
{
var result = new CatalogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetPurchasesComplete(ResultContainer resultContainer)
{
var result = new PurchasesResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPurchaseComplete(ResultContainer resultContainer)
{
var result = new PurchaseResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnConsumePurchaseComplete(ResultContainer resultContainer)
{
var result = new ConsumePurchaseResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetSubscribableCatalogComplete(ResultContainer resultContainer)
{
var result = new SubscribableCatalogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetSubscriptionsComplete(ResultContainer resultContainer)
{
var result = new SubscriptionsResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPurchaseSubscriptionComplete(ResultContainer resultContainer)
{
var result = new SubscriptionResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnCancelSubscriptionComplete(ResultContainer resultContainer)
{
var result = new CancelSubscriptionResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnInitCloudGameComplete(ResultContainer resultContainer)
{
var result = new InitCloudGameResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGameLoadCompleteComplete(ResultContainer resultContainer)
{
var result = new GameLoadCompleteResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnScheduleAppToUserNotificationComplete(ResultContainer resultContainer)
{
var result = new ScheduleAppToUserNotificationResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnLoadInterstitialAdComplete(ResultContainer resultContainer)
{
var result = new InterstitialAdResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnShowInterstitialAdComplete(ResultContainer resultContainer)
{
var result = new InterstitialAdResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnLoadRewardedVideoComplete(ResultContainer resultContainer)
{
var result = new RewardedVideoResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnShowRewardedVideoComplete(ResultContainer resultContainer)
{
var result = new RewardedVideoResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetPayloadComplete(ResultContainer resultContainer)
{
var result = new PayloadResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPostSessionScoreComplete(ResultContainer resultContainer)
{
var result = new SessionScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPostTournamentScoreComplete(ResultContainer resultContainer)
{
var result = new TournamentScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnShareTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnCreateTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetTournamentsComplete(ResultContainer resultContainer)
{
var result = new GetTournamentsResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnUpdateTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnTournamentDialogSuccess(ResultContainer resultContainer)
{
var result = new TournamentResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnTournamentDialogError(ResultContainer resultContainer)
{
var result = new AbortDialogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnTournamentDialogCancel(ResultContainer resultContainer)
{
var result = new AbortDialogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnOpenAppStoreComplete(ResultContainer resultContainer)
{
var result = new OpenAppStoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnCreateGamingContextComplete(ResultContainer resultContainer)
{
var result = new CreateGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnSwitchGamingContextComplete(ResultContainer resultContainer)
{
var result = new SwitchGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnChooseGamingContextComplete(ResultContainer resultContainer)
{
var result = new ChooseGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetCurrentGamingContextComplete(ResultContainer resultContainer)
{
var result = new GetCurrentGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void UploadImageToMediaLibrary(
string caption,
Uri imageUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
throw new NotImplementedException();
}
public override void UploadVideoToMediaLibrary(
string caption,
Uri videoUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
throw new NotImplementedException();
}
public virtual void OnIAPReady(
FacebookDelegate<IIAPReadyResult> callback)
{
throw new NotImplementedException();
}
public override void GetCatalog(
FacebookDelegate<ICatalogResult> callback)
{
throw new NotImplementedException();
}
public override void GetPurchases(
FacebookDelegate<IPurchasesResult> callback)
{
throw new NotImplementedException();
}
public override void Purchase(
string productID,
FacebookDelegate<IPurchaseResult> callback,
string developerPayload)
{
throw new NotImplementedException();
}
public override void ConsumePurchase(
string purchaseToken,
FacebookDelegate<IConsumePurchaseResult> callback)
{
throw new NotImplementedException();
}
public override void GetSubscribableCatalog(
FacebookDelegate<ISubscribableCatalogResult> callback)
{
throw new NotImplementedException();
}
public override void GetSubscriptions(
FacebookDelegate<ISubscriptionsResult> callback)
{
throw new NotImplementedException();
}
public override void PurchaseSubscription(
string productToken,
FacebookDelegate<ISubscriptionResult> callback)
{
throw new NotImplementedException();
}
public override void CancelSubscription(
string purchaseToken,
FacebookDelegate<ICancelSubscriptionResult> callback)
{
throw new NotImplementedException();
}
public virtual void InitCloudGame(
FacebookDelegate<IInitCloudGameResult> callback)
{
throw new NotImplementedException();
}
public virtual void GameLoadComplete(
FacebookDelegate<IGameLoadCompleteResult> callback)
{
throw new NotImplementedException();
}
public override void ScheduleAppToUserNotification(
string title,
string body,
Uri media,
int timeInterval,
string payload,
FacebookDelegate<IScheduleAppToUserNotificationResult> callback)
{
throw new NotImplementedException();
}
public override void LoadInterstitialAd(
string placementID,
FacebookDelegate<IInterstitialAdResult> callback)
{
throw new NotImplementedException();
}
public override void ShowInterstitialAd(
string placementID,
FacebookDelegate<IInterstitialAdResult> callback)
{
throw new NotImplementedException();
}
public override void LoadRewardedVideo(
string placementID,
FacebookDelegate<IRewardedVideoResult> callback)
{
throw new NotImplementedException();
}
public override void ShowRewardedVideo(
string placementID,
FacebookDelegate<IRewardedVideoResult> callback)
{
throw new NotImplementedException();
}
public virtual void GetPayload(
FacebookDelegate<IPayloadResult> callback)
{
throw new NotImplementedException();
}
public override void PostSessionScore(
int score,
FacebookDelegate<ISessionScoreResult> callback)
{
throw new NotImplementedException();
}
public override void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback)
{
throw new NotImplementedException();
}
public override void GetTournament(FacebookDelegate<ITournamentResult> callback)
{
throw new NotImplementedException();
}
public override void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback)
{
throw new NotImplementedException();
}
public override void CreateTournament(
int initialScore,
string title,
string imageBase64DataUrl,
string sortOrder,
string scoreFormat,
Dictionary<string, string> data,
FacebookDelegate<ITournamentResult> callback)
{
throw new NotImplementedException();
}
public virtual void GetTournaments(FacebookDelegate<IGetTournamentsResult> callback)
{
throw new NotImplementedException();
}
public virtual void UpdateTournament(string tournamentID, int score, FacebookDelegate<ITournamentScoreResult> callback)
{
throw new NotImplementedException();
}
public virtual void UpdateAndShareTournament(string tournamentID, int score, FacebookDelegate<IDialogResult> callback)
{
throw new NotImplementedException();
}
public virtual void CreateAndShareTournament(
int initialScore,
string title,
TournamentSortOrder sortOrder,
TournamentScoreFormat scoreFormat,
long endTime,
string payload,
FacebookDelegate<IDialogResult> callback)
{
throw new NotImplementedException();
}
public virtual void OpenAppStore(
FacebookDelegate<IOpenAppStoreResult> callback)
{
throw new NotImplementedException();
}
public virtual void CreateGamingContext(string playerID, FacebookDelegate<ICreateGamingContextResult> callback)
{
throw new NotImplementedException();
}
public virtual void SwitchGamingContext(string gamingContextID, FacebookDelegate<ISwitchGamingContextResult> callback)
{
throw new NotImplementedException();
}
public virtual void ChooseGamingContext(List<string> filters, int minSize, int maxSize, FacebookDelegate<IChooseGamingContextResult> callback)
{
throw new NotImplementedException();
}
public virtual void GetCurrentGamingContext(FacebookDelegate<IGetCurrentGamingContextResult> callback)
{
throw new NotImplementedException();
}
protected abstract void SetShareDialogMode(ShareDialogMode mode);
private static IDictionary<string, object> DeserializeMessage(string message)
{
return (Dictionary<string, object>)MiniJSON.Json.Deserialize(message);
}
private static string SerializeDictionary(IDictionary<string, object> dict)
{
return MiniJSON.Json.Serialize(dict);
}
private static bool TryGetCallbackId(IDictionary<string, object> result, out string callbackId)
{
object callback;
callbackId = null;
if (result.TryGetValue("callback_id", out callback))
{
callbackId = callback as string;
return true;
}
return false;
}
private static bool TryGetError(IDictionary<string, object> result, out string errorMessage)
{
object error;
errorMessage = null;
if (result.TryGetValue("error", out error))
{
errorMessage = error as string;
return true;
}
return false;
}
}
}
| 624 |
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.Mobile
{
internal abstract class MobileFacebookGameObject : FacebookGameObject,IMobileFacebookCallbackHandler
{
private IMobileFacebookImplementation MobileFacebook
{
get
{
return (IMobileFacebookImplementation)this.Facebook;
}
}
public void OnFetchDeferredAppLinkComplete(string message)
{
this.MobileFacebook.OnFetchDeferredAppLinkComplete(new ResultContainer(message));
}
public void OnRefreshCurrentAccessTokenComplete(string message)
{
this.MobileFacebook.OnRefreshCurrentAccessTokenComplete(new ResultContainer(message));
}
public void OnFriendFinderComplete(string message)
{
this.MobileFacebook.OnFriendFinderComplete(new ResultContainer(message));
}
public void OnUploadImageToMediaLibraryComplete(string message)
{
this.MobileFacebook.OnUploadImageToMediaLibraryComplete(new ResultContainer(message));
}
public void OnUploadVideoToMediaLibraryComplete(string message)
{
this.MobileFacebook.OnUploadVideoToMediaLibraryComplete(new ResultContainer(message));
}
public void OnOnIAPReadyComplete(string message)
{
this.MobileFacebook.OnOnIAPReadyComplete(new ResultContainer(message));
}
public void OnGetCatalogComplete(string message)
{
this.MobileFacebook.OnGetCatalogComplete(new ResultContainer(message));
}
public void OnGetPurchasesComplete(string message)
{
this.MobileFacebook.OnGetPurchasesComplete(new ResultContainer(message));
}
public void OnPurchaseComplete(string message)
{
this.MobileFacebook.OnPurchaseComplete(new ResultContainer(message));
}
public void OnConsumePurchaseComplete(string message)
{
this.MobileFacebook.OnConsumePurchaseComplete(new ResultContainer(message));
}
public void OnGetSubscribableCatalogComplete(string message)
{
this.MobileFacebook.OnGetSubscribableCatalogComplete(new ResultContainer(message));
}
public void OnGetSubscriptionsComplete(string message)
{
this.MobileFacebook.OnGetSubscriptionsComplete(new ResultContainer(message));
}
public void OnPurchaseSubscriptionComplete(string message)
{
this.MobileFacebook.OnPurchaseSubscriptionComplete(new ResultContainer(message));
}
public void OnCancelSubscriptionComplete(string message)
{
this.MobileFacebook.OnCancelSubscriptionComplete(new ResultContainer(message));
}
public void OnInitCloudGameComplete(string message)
{
this.MobileFacebook.OnInitCloudGameComplete(new ResultContainer(message));
}
public void OnGameLoadCompleteComplete(string message)
{
this.MobileFacebook.OnGameLoadCompleteComplete(new ResultContainer(message));
}
public void OnScheduleAppToUserNotificationComplete(string message)
{
this.MobileFacebook.OnScheduleAppToUserNotificationComplete(new ResultContainer(message));
}
public void OnLoadInterstitialAdComplete(string message)
{
this.MobileFacebook.OnLoadInterstitialAdComplete(new ResultContainer(message));
}
public void OnShowInterstitialAdComplete(string message)
{
this.MobileFacebook.OnShowInterstitialAdComplete(new ResultContainer(message));
}
public void OnLoadRewardedVideoComplete(string message)
{
this.MobileFacebook.OnLoadRewardedVideoComplete(new ResultContainer(message));
}
public void OnShowRewardedVideoComplete(string message)
{
this.MobileFacebook.OnShowRewardedVideoComplete(new ResultContainer(message));
}
public void OnGetPayloadComplete(string message)
{
this.MobileFacebook.OnGetPayloadComplete(new ResultContainer(message));
}
public virtual void OnPostSessionScoreComplete(string message)
{
this.MobileFacebook.OnPostSessionScoreComplete(new ResultContainer(message));
}
public virtual void OnPostTournamentScoreComplete(string message)
{
this.MobileFacebook.OnPostTournamentScoreComplete(new ResultContainer(message));
}
public virtual void OnGetTournamentComplete(string message)
{
this.MobileFacebook.OnGetTournamentComplete(new ResultContainer(message));
}
public virtual void OnShareTournamentComplete(string message)
{
this.MobileFacebook.OnShareTournamentComplete(new ResultContainer(message));
}
public virtual void OnCreateTournamentComplete(string message)
{
this.MobileFacebook.OnCreateTournamentComplete(new ResultContainer(message));
}
public virtual void OnGetTournamentsComplete(string message)
{
this.MobileFacebook.OnGetTournamentsComplete(new ResultContainer(message));
}
public virtual void OnUpdateTournamentComplete(string message)
{
this.MobileFacebook.OnUpdateTournamentComplete(new ResultContainer(message));
}
public virtual void OnTournamentDialogSuccess(string message)
{
this.MobileFacebook.OnTournamentDialogSuccess(new ResultContainer(message));
}
public virtual void OnTournamentDialogCancel(string message)
{
this.MobileFacebook.OnTournamentDialogCancel(new ResultContainer(message));
}
public virtual void OnTournamentDialogError(string message)
{
this.MobileFacebook.OnTournamentDialogError(new ResultContainer(message));
}
public void OnOpenAppStoreComplete(string message)
{
this.MobileFacebook.OnOpenAppStoreComplete(new ResultContainer(message));
}
public void OnCreateGamingContextComplete(string message)
{
this.MobileFacebook.OnCreateGamingContextComplete(new ResultContainer(message));
}
public void OnSwitchGamingContextComplete(string message)
{
this.MobileFacebook.OnSwitchGamingContextComplete(new ResultContainer(message));
}
public void OnChooseGamingContextComplete(string message)
{
this.MobileFacebook.OnChooseGamingContextComplete(new ResultContainer(message));
}
public void OnGetCurrentGamingContextComplete(string message)
{
this.MobileFacebook.OnGetCurrentGamingContextComplete(new ResultContainer(message));
}
}
}
| 222 |
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.Mobile.Android
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Reflection;
using UnityEngine;
internal sealed class AndroidFacebook : MobileFacebook
{
public const string LoginPermissionsKey = "scope";
// This class holds all the of the wrapper methods that we call into
private bool limitEventUsage;
private IAndroidWrapper androidWrapper;
private string userID;
public AndroidFacebook() : this(GetAndroidWrapper(), new CallbackManager())
{
}
public AndroidFacebook(IAndroidWrapper androidWrapper, CallbackManager callbackManager)
: base(callbackManager)
{
this.KeyHash = string.Empty;
this.androidWrapper = androidWrapper;
}
// key Hash used for Android SDK
public string KeyHash { get; private set; }
public override bool LimitEventUsage
{
get
{
return this.limitEventUsage;
}
set
{
this.limitEventUsage = value;
this.CallFB("SetLimitEventUsage", value.ToString());
}
}
public override string UserID
{
get
{
return userID;
}
set
{
this.userID = value;
this.CallFB("SetUserID", value);
}
}
public override void SetDataProcessingOptions(IEnumerable<string> options, int country, int state)
{
var args = new MethodArguments();
args.AddList<string>("options", options);
args.AddPrimative<int>("country", country);
args.AddPrimative<int>("state", state);
this.CallFB("SetDataProcessingOptions", args.ToJsonString());
}
public override void SetAutoLogAppEventsEnabled(bool autoLogAppEventsEnabled)
{
this.CallFB("SetAutoLogAppEventsEnabled", autoLogAppEventsEnabled.ToString());
}
public override void SetAdvertiserIDCollectionEnabled(bool advertiserIDCollectionEnabled)
{
this.CallFB("SetAdvertiserIDCollectionEnabled", advertiserIDCollectionEnabled.ToString());
}
public override bool SetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled)
{
return false;
}
public override void SetPushNotificationsDeviceTokenString(string token)
{
this.CallFB("SetPushNotificationsDeviceTokenString", token);
}
public override string SDKName
{
get
{
return "FBAndroidSDK";
}
}
public override string SDKVersion
{
get
{
return this.androidWrapper.CallStatic<string>("GetSdkVersion");
}
}
public void Init(
string appId,
string clientToken,
HideUnityDelegate hideUnityDelegate,
InitDelegate onInitComplete)
{
// Set the user agent suffix for graph requests
// This should be set before a call to init to ensure that
// requests made during init include this suffix.
this.CallFB(
"SetUserAgentSuffix",
string.Format(Constants.UnitySDKUserAgentSuffixLegacy));
base.Init(onInitComplete);
var args = new MethodArguments();
args.AddString("appId", appId);
args.AddString("clientToken", clientToken);
var initCall = new JavaMethodCall<IResult>(this, "Init");
initCall.Call(args);
this.userID = this.androidWrapper.CallStatic<string>("GetUserID");
}
public override void EnableProfileUpdatesOnAccessTokenChange(bool enable)
{
if (Debug.isDebugBuild)
{
Debug.Log("This function is only implemented on iOS.");
}
return;
}
public override void LoginWithTrackingPreference(
string tracking,
IEnumerable<string> permissions,
string nonce,
FacebookDelegate<ILoginResult> callback)
{
if (Debug.isDebugBuild)
{
Debug.Log("This function is only implemented on iOS. Please use .LoginWithReadPermissions() or .LoginWithPublishPermissions() on other platforms.");
}
return;
}
public override void LogInWithReadPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddCommaSeparatedList(AndroidFacebook.LoginPermissionsKey, permissions);
var loginCall = new JavaMethodCall<ILoginResult>(this, "LoginWithReadPermissions");
loginCall.Callback = callback;
loginCall.Call(args);
}
public override void LogInWithPublishPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddCommaSeparatedList(AndroidFacebook.LoginPermissionsKey, permissions);
var loginCall = new JavaMethodCall<ILoginResult>(this, "LoginWithPublishPermissions");
loginCall.Callback = callback;
loginCall.Call(args);
}
public override void LogOut()
{
base.LogOut();
var logoutCall = new JavaMethodCall<IResult>(this, "Logout");
logoutCall.Call();
}
public override AuthenticationToken CurrentAuthenticationToken()
{
String authTokenString = this.androidWrapper.CallStatic<string>("GetCurrentAuthenticationToken");
if (!String.IsNullOrEmpty(authTokenString))
{
IDictionary<string, string> token = Utilities.ParseStringDictionaryFromString(authTokenString);
string tokenString;
string nonce;
token.TryGetValue("auth_token_string", out tokenString);
token.TryGetValue("auth_nonce", out nonce);
try
{
return new AuthenticationToken(tokenString, nonce);
}
catch (Exception)
{
Debug.Log("An unexpected error occurred while retrieving the current authentication token");
}
}
return null;
}
public override Profile CurrentProfile()
{
String profileString = this.androidWrapper.CallStatic<string>("GetCurrentProfile");
if (!String.IsNullOrEmpty(profileString))
{
try
{
IDictionary<string, string> profile = Utilities.ParseStringDictionaryFromString(profileString);
string id;
string firstName;
string middleName;
string lastName;
string name;
string email;
string imageURL;
string linkURL;
string friendIDs;
string birthday;
string gender;
profile.TryGetValue("userID", out id);
profile.TryGetValue("firstName", out firstName);
profile.TryGetValue("middleName", out middleName);
profile.TryGetValue("lastName", out lastName);
profile.TryGetValue("name", out name);
profile.TryGetValue("email", out email);
profile.TryGetValue("imageURL", out imageURL);
profile.TryGetValue("linkURL", out linkURL);
profile.TryGetValue("friendIDs", out friendIDs);
profile.TryGetValue("birthday", out birthday);
profile.TryGetValue("gender", out gender);
UserAgeRange ageRange = UserAgeRange.AgeRangeFromDictionary(profile);
FBLocation hometown = FBLocation.FromDictionary("hometown", profile);
FBLocation location = FBLocation.FromDictionary("location", profile);
return new Profile(
userID,
firstName,
middleName,
lastName,
name,
email,
imageURL,
linkURL,
friendIDs?.Split(','),
birthday,
ageRange,
hometown,
location,
gender);
}
catch (Exception)
{
return null;
}
}
return null;
}
public void RetrieveLoginStatus(FacebookDelegate<ILoginStatusResult> callback) {
var loginCall = new JavaMethodCall<ILoginStatusResult>(this, "RetrieveLoginStatus");
loginCall.Callback = callback;
loginCall.Call();
}
public void OnLoginStatusRetrieved(ResultContainer resultContainer)
{
var result = new LoginStatusResult(resultContainer);
this.OnAuthResponse(result);
}
public override 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)
{
this.ValidateAppRequestArgs(
message,
actionType,
objectId,
to,
filters,
excludeIds,
maxRecipients,
data,
title,
callback);
MethodArguments args = new MethodArguments();
args.AddString("message", message);
args.AddNullablePrimitive("action_type", actionType);
args.AddString("object_id", objectId);
args.AddCommaSeparatedList("to", to);
if (filters != null && filters.Any())
{
string mobileFilter = filters.First() as string;
if (mobileFilter != null)
{
args.AddString("filters", mobileFilter);
}
}
args.AddNullablePrimitive("max_recipients", maxRecipients);
args.AddString("data", data);
args.AddString("title", title);
var appRequestCall = new JavaMethodCall<IAppRequestResult>(this, "AppRequest");
appRequestCall.Callback = callback;
appRequestCall.Call(args);
}
public override void ShareLink(
Uri contentURL,
string contentTitle,
string contentDescription,
Uri photoURL,
FacebookDelegate<IShareResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddUri("content_url", contentURL);
args.AddString("content_title", contentTitle);
args.AddString("content_description", contentDescription);
args.AddUri("photo_url", photoURL);
var shareLinkCall = new JavaMethodCall<IShareResult>(this, "ShareLink");
shareLinkCall.Callback = callback;
shareLinkCall.Call(args);
}
public override void FeedShare(
string toId,
Uri link,
string linkName,
string linkCaption,
string linkDescription,
Uri picture,
string mediaSource,
FacebookDelegate<IShareResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("toId", toId);
args.AddUri("link", link);
args.AddString("linkName", linkName);
args.AddString("linkCaption", linkCaption);
args.AddString("linkDescription", linkDescription);
args.AddUri("picture", picture);
args.AddString("mediaSource", mediaSource);
var call = new JavaMethodCall<IShareResult>(this, "FeedShare");
call.Callback = callback;
call.Call(args);
}
public override void GetAppLink(
FacebookDelegate<IAppLinkResult> callback)
{
var getAppLink = new JavaMethodCall<IAppLinkResult>(this, "GetAppLink");
getAppLink.Callback = callback;
getAppLink.Call();
}
public void ClearAppLink()
{
this.CallFB("ClearAppLink", null);
}
public override void AppEventsLogEvent(
string logEvent,
float? valueToSum,
Dictionary<string, object> parameters)
{
MethodArguments args = new MethodArguments();
args.AddString("logEvent", logEvent);
args.AddString("valueToSum", valueToSum?.ToString(CultureInfo.InvariantCulture));
args.AddDictionary("parameters", parameters);
var appEventcall = new JavaMethodCall<IResult>(this, "LogAppEvent");
appEventcall.Call(args);
}
public override void AppEventsLogPurchase(
float logPurchase,
string currency,
Dictionary<string, object> parameters)
{
MethodArguments args = new MethodArguments();
args.AddString("logPurchase", logPurchase.ToString(CultureInfo.InvariantCulture));
args.AddString("currency", currency);
args.AddDictionary("parameters", parameters);
var logPurchaseCall = new JavaMethodCall<IResult>(this, "LogAppEvent");
logPurchaseCall.Call(args);
}
public override bool IsImplicitPurchaseLoggingEnabled()
{
return this.androidWrapper.CallStatic<bool>("IsImplicitPurchaseLoggingEnabled");
}
public override void ActivateApp(string appId)
{
this.CallFB("ActivateApp", null);
}
public override void FetchDeferredAppLink(
FacebookDelegate<IAppLinkResult> callback)
{
MethodArguments args = new MethodArguments();
var fetchDeferredAppLinkData = new JavaMethodCall<IAppLinkResult>(this, "FetchDeferredAppLinkData");
fetchDeferredAppLinkData.Callback = callback;
fetchDeferredAppLinkData.Call(args);
}
public override void RefreshCurrentAccessToken(
FacebookDelegate<IAccessTokenRefreshResult> callback)
{
var refreshCurrentAccessToken = new JavaMethodCall<IAccessTokenRefreshResult>(
this,
"RefreshCurrentAccessToken");
refreshCurrentAccessToken.Callback = callback;
refreshCurrentAccessToken.Call();
}
public override void OpenFriendFinderDialog(
FacebookDelegate<IGamingServicesFriendFinderResult> callback)
{
var openFriendFinderDialog = new JavaMethodCall<IGamingServicesFriendFinderResult>(
this,
"OpenFriendFinderDialog")
{
Callback = callback
};
openFriendFinderDialog.Call();
}
public override void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void UploadImageToMediaLibrary(
string caption,
Uri imageUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("caption", caption);
args.AddUri("imageUri", imageUri);
args.AddString("shouldLaunchMediaDialog", shouldLaunchMediaDialog.ToString());
var uploadImageToMediaLibrary = new JavaMethodCall<IMediaUploadResult>(
this,
"UploadImageToMediaLibrary")
{
Callback = callback
};
uploadImageToMediaLibrary.Call(args);
}
public override void UploadVideoToMediaLibrary(
string caption,
Uri videoUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("caption", caption);
args.AddUri("videoUri", videoUri);
var uploadImageToMediaLibrary = new JavaMethodCall<IMediaUploadResult>(
this,
"UploadVideoToMediaLibrary")
{
Callback = callback
};
uploadImageToMediaLibrary.Call(args);
}
public override void GetUserLocale(FacebookDelegate<ILocaleResult> callback)
{
throw new NotImplementedException();
}
public override void OnIAPReady(
FacebookDelegate<IIAPReadyResult> callback)
{
var onIAPReady = new JavaMethodCall<IIAPReadyResult>(
this,
"OnIAPReady")
{
Callback = callback
};
onIAPReady.Call();
}
public override void GetCatalog(
FacebookDelegate<ICatalogResult> callback)
{
var getCatalog = new JavaMethodCall<ICatalogResult>(
this,
"GetCatalog")
{
Callback = callback
};
getCatalog.Call();
}
public override void GetPurchases(
FacebookDelegate<IPurchasesResult> callback)
{
var getPurchases = new JavaMethodCall<IPurchasesResult>(
this,
"GetPurchases")
{
Callback = callback
};
getPurchases.Call();
}
public override void Purchase(
string productID,
FacebookDelegate<IPurchaseResult> callback,
string developerPayload = "")
{
MethodArguments args = new MethodArguments();
args.AddString("productID", productID);
args.AddString("developerPayload", developerPayload);
var purchase = new JavaMethodCall<IPurchaseResult>(
this,
"Purchase")
{
Callback = callback
};
purchase.Call(args);
}
public override void ConsumePurchase(
string purchaseToken,
FacebookDelegate<IConsumePurchaseResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("purchaseToken", purchaseToken);
var consumePurchase = new JavaMethodCall<IConsumePurchaseResult>(
this,
"ConsumePurchase")
{
Callback = callback
};
consumePurchase.Call(args);
}
public override void GetSubscribableCatalog(
FacebookDelegate<ISubscribableCatalogResult> callback)
{
var getSubscribableCatalog = new JavaMethodCall<ISubscribableCatalogResult>(
this,
"GetSubscribableCatalog")
{
Callback = callback
};
getSubscribableCatalog.Call();
}
public override void GetSubscriptions(
FacebookDelegate<ISubscriptionsResult> callback)
{
var getSubscriptions = new JavaMethodCall<ISubscriptionsResult>(
this,
"GetSubscriptions")
{
Callback = callback
};
getSubscriptions.Call();
}
public override void PurchaseSubscription(
string productID,
FacebookDelegate<ISubscriptionResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("productID", productID);
var subscription = new JavaMethodCall<ISubscriptionResult>(
this,
"PurchaseSubscription")
{
Callback = callback
};
subscription.Call(args);
}
public override void CancelSubscription(
string purchaseToken,
FacebookDelegate<ICancelSubscriptionResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("purchaseToken", purchaseToken);
var cancelSubscription = new JavaMethodCall<ICancelSubscriptionResult>(
this,
"CancelSubscription")
{
Callback = callback
};
cancelSubscription.Call(args);
}
public override void InitCloudGame(
FacebookDelegate<IInitCloudGameResult> callback)
{
var initCloudGame = new JavaMethodCall<IInitCloudGameResult>(
this,
"InitCloudGame")
{
Callback = callback
};
initCloudGame.Call();
}
public override void GameLoadComplete(
FacebookDelegate<IGameLoadCompleteResult> callback)
{
var gameLoadComplete = new JavaMethodCall<IGameLoadCompleteResult>(
this,
"GameLoadComplete")
{
Callback = callback
};
gameLoadComplete.Call();
}
public override void ScheduleAppToUserNotification(
string title,
string body,
Uri media,
int timeInterval,
string payload,
FacebookDelegate<IScheduleAppToUserNotificationResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("title", title);
args.AddString("body", body);
args.AddUri("media", media);
args.AddPrimative("timeInterval", timeInterval);
args.AddString("payload", payload);
var scheduleAppToUserNotification = new JavaMethodCall<IScheduleAppToUserNotificationResult>(
this,
"ScheduleAppToUserNotification")
{
Callback = callback
};
scheduleAppToUserNotification.Call(args);
}
public override void LoadInterstitialAd(
string placementID,
FacebookDelegate<IInterstitialAdResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("placementID", placementID);
var loadInterstitialAd = new JavaMethodCall<IInterstitialAdResult>(
this,
"LoadInterstitialAd")
{
Callback = callback
};
loadInterstitialAd.Call(args);
}
public override void ShowInterstitialAd(
string placementID,
FacebookDelegate<IInterstitialAdResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("placementID", placementID);
var showInterstitialAd = new JavaMethodCall<IInterstitialAdResult>(
this,
"ShowInterstitialAd")
{
Callback = callback
};
showInterstitialAd.Call(args);
}
public override void LoadRewardedVideo(
string placementID,
FacebookDelegate<IRewardedVideoResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("placementID", placementID);
var loadRewardedVideo = new JavaMethodCall<IRewardedVideoResult>(
this,
"LoadRewardedVideo")
{
Callback = callback
};
loadRewardedVideo.Call(args);
}
public override void ShowRewardedVideo(
string placementID,
FacebookDelegate<IRewardedVideoResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("placementID", placementID);
var showRewardedVideo = new JavaMethodCall<IRewardedVideoResult>(
this,
"ShowRewardedVideo")
{
Callback = callback
};
showRewardedVideo.Call(args);
}
public override void GetPayload(
FacebookDelegate<IPayloadResult> callback)
{
var getPayload = new JavaMethodCall<IPayloadResult>(
this,
"GetPayload")
{
Callback = callback
};
getPayload.Call();
}
public override void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("score", score.ToString());
var postSessionScore = new JavaMethodCall<ISessionScoreResult>(
this,
"PostSessionScore")
{
Callback = callback
};
postSessionScore.Call(args);
}
public override void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("score", score.ToString());
var postTournamentScore = new JavaMethodCall<ITournamentScoreResult>(
this,
"PostTournamentScore")
{
Callback = callback
};
postTournamentScore.Call(args);
}
public override void GetTournament(FacebookDelegate<ITournamentResult> callback)
{
var getTournament = new JavaMethodCall<ITournamentResult>(
this,
"GetTournament")
{
Callback = callback
};
getTournament.Call();
}
public override void CreateTournament(
int initialScore,
string title,
string imageBase64DataUrl,
string sortOrder,
string scoreFormat,
Dictionary<string, string> data,
FacebookDelegate<ITournamentResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("initialScore", initialScore.ToString());
args.AddString("title", title);
args.AddString("imageBase64DataUrl", imageBase64DataUrl);
args.AddString("sortOrder", sortOrder);
args.AddString("scoreFormat", scoreFormat);
args.AddDictionary("data", data.ToDictionary( pair => pair.Key, pair => (object) pair.Value));
var createTournament = new JavaMethodCall<ITournamentResult>(
this,
"CreateTournament")
{
Callback = callback
};
createTournament.Call(args);
}
public override void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("score", score.ToString());
args.AddDictionary("data", data.ToDictionary(pair => pair.Key, pair => (object)pair.Value));
var shareTournament = new JavaMethodCall<ITournamentScoreResult>(
this,
"ShareTournament")
{
Callback = callback
};
shareTournament.Call(args);
}
public override void GetTournaments(FacebookDelegate<IGetTournamentsResult> callback)
{
var getTournaments = new JavaMethodCall<IGetTournamentsResult>(
this,
"GetTournaments")
{
Callback = callback
};
getTournaments.Call();
}
public override void UpdateTournament(string tournamentID, int score, FacebookDelegate<ITournamentScoreResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("tournamentID", tournamentID);
args.AddString("score", score.ToString());
var updateTournament = new JavaMethodCall<ITournamentScoreResult>(
this,
"UpdateTournament")
{
Callback = callback
};
updateTournament.Call(args);
}
public override void UpdateAndShareTournament(string tournamentID, int score, FacebookDelegate<IDialogResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("tournamentID", tournamentID);
args.AddString("score", score.ToString());
var updateAndShareTournament = new JavaMethodCall<IDialogResult>(
this,
"UpdateAndShareTournament")
{
Callback = callback
};
updateAndShareTournament.Call(args);
}
public override void CreateAndShareTournament(
int initialScore,
string title,
TournamentSortOrder sortOrder,
TournamentScoreFormat scoreFormat,
long endTime,
string payload,
FacebookDelegate<IDialogResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("initialScore", initialScore.ToString());
args.AddString("title", title);
args.AddString("sortOrder", sortOrder == TournamentSortOrder.HigherIsBetter ? "HigherIsBetter" : "LowerIsBetter");
args.AddString("scoreType", scoreFormat == TournamentScoreFormat.Numeric ? "Numeric" : "Time");
args.AddString("endTime", endTime.ToString());
args.AddString("payload", payload.ToString());
var createAndShareTournament = new JavaMethodCall<IDialogResult>(
this,
"CreateAndShareTournament")
{
Callback = callback
};
createAndShareTournament.Call(args);
}
public override void OpenAppStore(
FacebookDelegate<IOpenAppStoreResult> callback)
{
var openAppStore = new JavaMethodCall<IOpenAppStoreResult>(
this,
"OpenAppStore")
{
Callback = callback
};
openAppStore.Call();
}
public override void CreateGamingContext(string playerID, FacebookDelegate<ICreateGamingContextResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("playerID", playerID);
var createGamingContext = new JavaMethodCall<ICreateGamingContextResult>(
this,
"CreateGamingContext")
{
Callback = callback
};
createGamingContext.Call(args);
}
public override void SwitchGamingContext(string gamingContextID, FacebookDelegate<ISwitchGamingContextResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddString("gamingContextID", gamingContextID);
var switchGamingContext = new JavaMethodCall<ISwitchGamingContextResult>(
this,
"SwitchGamingContext")
{
Callback = callback
};
switchGamingContext.Call(args);
}
public override void ChooseGamingContext(List<string> filters, int minSize, int maxSize, FacebookDelegate<IChooseGamingContextResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddList<string>("filters", filters);
args.AddPrimative<int>("minSize", minSize);
args.AddPrimative<int>("maxSize", maxSize);
var chooseGamingContext = new JavaMethodCall<IChooseGamingContextResult>(
this,
"ChooseGamingContext")
{
Callback = callback
};
chooseGamingContext.Call(args);
}
public override void GetCurrentGamingContext(FacebookDelegate<IGetCurrentGamingContextResult> callback)
{
MethodArguments args = new MethodArguments();
var getCurrentGamingContext = new JavaMethodCall<IGetCurrentGamingContextResult>(
this,
"GetCurrentGamingContext")
{
Callback = callback
};
getCurrentGamingContext.Call(args);
}
protected override void SetShareDialogMode(ShareDialogMode mode)
{
this.CallFB("SetShareDialogMode", mode.ToString());
}
private static IAndroidWrapper GetAndroidWrapper()
{
Assembly assembly = Assembly.Load("Facebook.Unity.Android");
Type type = assembly.GetType("Facebook.Unity.Android.AndroidWrapper");
IAndroidWrapper javaClass = (IAndroidWrapper)Activator.CreateInstance(type);
return javaClass;
}
private void CallFB(string method, string args)
{
this.androidWrapper.CallStatic(method, args);
}
private class JavaMethodCall<T> : MethodCall<T> where T : IResult
{
private AndroidFacebook androidImpl;
public JavaMethodCall(AndroidFacebook androidImpl, string methodName)
: base(androidImpl, methodName)
{
this.androidImpl = androidImpl;
}
public override void Call(MethodArguments args = null)
{
MethodArguments paramsCopy;
if (args == null)
{
paramsCopy = new MethodArguments();
}
else
{
paramsCopy = new MethodArguments(args);
}
if (this.Callback != null)
{
paramsCopy.AddString("callback_id", this.androidImpl.CallbackManager.AddFacebookDelegate(this.Callback));
}
this.androidImpl.CallFB(this.MethodName, paramsCopy.ToJsonString());
}
}
}
}
| 1,015 |
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.Mobile.Android
{
using UnityEngine.SceneManagement;
internal class AndroidFacebookGameObject : MobileFacebookGameObject
{
protected override void OnAwake()
{
CodelessIAPAutoLog.addListenerToIAPButtons(this);
}
void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
CodelessIAPAutoLog.addListenerToIAPButtons(this);
}
void OnDisable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
public void onPurchaseCompleteHandler(System.Object data) {
CodelessIAPAutoLog.handlePurchaseCompleted(data);
}
public void OnLoginStatusRetrieved(string message)
{
((AndroidFacebook)this.Facebook).OnLoginStatusRetrieved(new ResultContainer(message));
}
}
}
| 57 |
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.Mobile.Android
{
internal class AndroidFacebookLoader : FB.CompiledFacebookLoader
{
protected override FacebookGameObject FBGameObject
{
get
{
AndroidFacebookGameObject androidFB = ComponentFactory.GetComponent<AndroidFacebookGameObject>();
if (androidFB.Facebook == null)
{
androidFB.Facebook = new AndroidFacebook();
}
return androidFB;
}
}
}
}
| 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.Mobile.Android
{
internal interface IAndroidWrapper
{
T CallStatic<T>(string methodName);
void CallStatic(string methodName, params object[] args);
}
}
| 30 |
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.Mobile.IOS
{
using System.Collections.Generic;
internal interface IIOSWrapper
{
void Init(
string appId,
bool frictionlessRequests,
string urlSuffix,
string unityUserAgentSuffix);
void EnableProfileUpdatesOnAccessTokenChange(bool enable);
void LogInWithReadPermissions(
int requestId,
string scope);
void LogInWithPublishPermissions(
int requestId,
string scope);
void LoginWithTrackingPreference(
int requestId,
string scope,
string tracking,
string nonce);
void LogOut();
void SetPushNotificationsDeviceTokenString(string token);
void SetShareDialogMode(int mode);
void ShareLink(
int requestId,
string contentURL,
string contentTitle,
string contentDescription,
string photoURL);
void FeedShare(
int requestId,
string toId,
string link,
string linkName,
string linkCaption,
string linkDescription,
string picture,
string mediaSource);
void AppRequest(
int requestId,
string message,
string actionType,
string objectId,
string[] to = null,
int toLength = 0,
string filters = "",
string[] excludeIds = null,
int excludeIdsLength = 0,
bool hasMaxRecipients = false,
int maxRecipients = 0,
string data = "",
string title = "");
void FBAppEventsActivateApp();
void LogAppEvent(
string logEvent,
double valueToSum,
int numParams,
string[] paramKeys,
string[] paramVals);
void LogPurchaseAppEvent(
double logPurchase,
string currency,
int numParams,
string[] paramKeys,
string[] paramVals);
void FBAppEventsSetLimitEventUsage(bool limitEventUsage);
void FBAutoLogAppEventsEnabled (bool autoLogAppEventsEnabled);
void FBAdvertiserIDCollectionEnabled(bool advertiserIDCollectionEnabledID);
bool FBAdvertiserTrackingEnabled(bool advertiserTrackingEnabled);
void GetAppLink(int requestId);
void RefreshCurrentAccessToken(int requestId);
string FBSdkVersion();
void FBSetUserID(string userID);
string FBGetUserID();
void SetDataProcessingOptions(string[] options, int country, int state);
void OpenFriendFinderDialog(int requestId);
void CreateGamingContext(int requestId, string playerID);
void SwitchGamingContext(int requestId, string gamingContextID);
void GetCurrentGamingContext(int requestId);
void ChooseGamingContext(
int requestId,
string filter,
int minSize,
int maxSize);
void GetTournaments(int requestId);
void UpdateTournament(string tournamentId, int score, int requestId);
void UpdateAndShareTournament(
string tournamentId,
int score,
int requestId);
void CreateAndShareTournament(
int initialScore,
string title,
TournamentSortOrder sortOrder,
TournamentScoreFormat scoreFormat,
long endTime,
string payload,
int requestId);
void UploadImageToMediaLibrary(
int requestId,
string caption,
string mediaUri,
bool shouldLaunchMediaDialog);
void UploadVideoToMediaLibrary(
int requestId,
string caption,
string videoUri);
void FetchDeferredAppLink(int requestId);
AuthenticationToken CurrentAuthenticationToken();
Profile CurrentProfile();
}
}
| 173 |
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.Mobile.IOS
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
internal class IOSFacebook : MobileFacebook
{
private const string CancelledResponse = "{\"cancelled\":true}";
private bool limitEventUsage;
private IIOSWrapper iosWrapper;
private string userID;
public IOSFacebook()
: this(GetIOSWrapper(), new CallbackManager())
{
}
public IOSFacebook(IIOSWrapper iosWrapper, CallbackManager callbackManager)
: base(callbackManager)
{
this.iosWrapper = iosWrapper;
}
public enum FBInsightsFlushBehavior
{
/// <summary>
/// The FB insights flush behavior auto.
/// </summary>
FBInsightsFlushBehaviorAuto,
/// <summary>
/// The FB insights flush behavior explicit only.
/// </summary>
FBInsightsFlushBehaviorExplicitOnly,
}
public override bool LimitEventUsage
{
get
{
return this.limitEventUsage;
}
set
{
this.limitEventUsage = value;
this.iosWrapper.FBAppEventsSetLimitEventUsage(value);
}
}
public override void SetAutoLogAppEventsEnabled(bool autoLogAppEventsEnabled)
{
this.iosWrapper.FBAutoLogAppEventsEnabled(autoLogAppEventsEnabled);
}
public override void SetAdvertiserIDCollectionEnabled(bool advertiserIDCollectionEnabled)
{
this.iosWrapper.FBAdvertiserIDCollectionEnabled(advertiserIDCollectionEnabled);
}
public override bool SetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled)
{
return this.iosWrapper.FBAdvertiserTrackingEnabled(advertiserTrackingEnabled);
}
public override void SetPushNotificationsDeviceTokenString(string token)
{
this.iosWrapper.SetPushNotificationsDeviceTokenString(token);
}
public override string SDKName
{
get
{
return "FBiOSSDK";
}
}
public override string SDKVersion
{
get
{
return this.iosWrapper.FBSdkVersion();
}
}
public override string UserID
{
get
{
return this.userID;
}
set
{
this.userID = value;
this.iosWrapper.FBSetUserID(value);
}
}
public override void SetDataProcessingOptions(IEnumerable<string> options, int country, int state)
{
this.iosWrapper.SetDataProcessingOptions(options.ToArray(), country, state);
}
public void Init(
string appId,
bool frictionlessRequests,
string iosURLSuffix,
HideUnityDelegate hideUnityDelegate,
InitDelegate onInitComplete)
{
base.Init(onInitComplete);
this.iosWrapper.Init(
appId,
frictionlessRequests,
iosURLSuffix,
Constants.UnitySDKUserAgentSuffixLegacy);
this.userID = this.iosWrapper.FBGetUserID();
}
public override void EnableProfileUpdatesOnAccessTokenChange(bool enable)
{
this.iosWrapper.EnableProfileUpdatesOnAccessTokenChange(enable);
}
public override void LoginWithTrackingPreference(
string tracking,
IEnumerable<string> permissions,
string nonce,
FacebookDelegate<ILoginResult> callback)
{
this.iosWrapper.LoginWithTrackingPreference(this.AddCallback(callback), permissions.ToCommaSeparateList(), tracking, nonce);
}
public override void LogInWithReadPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
this.iosWrapper.LogInWithReadPermissions(this.AddCallback(callback), permissions.ToCommaSeparateList());
}
public override void LogInWithPublishPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
this.iosWrapper.LogInWithPublishPermissions(this.AddCallback(callback), permissions.ToCommaSeparateList());
}
public override void LogOut()
{
base.LogOut();
this.iosWrapper.LogOut();
}
public override bool LoggedIn
{
get
{
AccessToken token = AccessToken.CurrentAccessToken;
AuthenticationToken authenticationToken = CurrentAuthenticationToken();
return (token != null && token.ExpirationTime > DateTime.UtcNow) || authenticationToken != null;
}
}
public override AuthenticationToken CurrentAuthenticationToken()
{
return this.iosWrapper.CurrentAuthenticationToken();
}
public override Profile CurrentProfile()
{
return this.iosWrapper.CurrentProfile();
}
public override 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)
{
this.ValidateAppRequestArgs(
message,
actionType,
objectId,
to,
filters,
excludeIds,
maxRecipients,
data,
title,
callback);
string mobileFilter = null;
if (filters != null && filters.Any())
{
mobileFilter = filters.First() as string;
}
this.iosWrapper.AppRequest(
this.AddCallback(callback),
message,
(actionType != null) ? actionType.ToString() : string.Empty,
objectId != null ? objectId : string.Empty,
to != null ? to.ToArray() : null,
to != null ? to.Count() : 0,
mobileFilter != null ? mobileFilter : string.Empty,
excludeIds != null ? excludeIds.ToArray() : null,
excludeIds != null ? excludeIds.Count() : 0,
maxRecipients.HasValue,
maxRecipients.HasValue ? maxRecipients.Value : 0,
data,
title);
}
public override void ShareLink(
Uri contentURL,
string contentTitle,
string contentDescription,
Uri photoURL,
FacebookDelegate<IShareResult> callback)
{
this.iosWrapper.ShareLink(
this.AddCallback(callback),
contentURL.AbsoluteUrlOrEmptyString(),
contentTitle,
contentDescription,
photoURL.AbsoluteUrlOrEmptyString());
}
public override void FeedShare(
string toId,
Uri link,
string linkName,
string linkCaption,
string linkDescription,
Uri picture,
string mediaSource,
FacebookDelegate<IShareResult> callback)
{
string linkStr = link != null ? link.ToString() : string.Empty;
string pictureStr = picture != null ? picture.ToString() : string.Empty;
this.iosWrapper.FeedShare(
this.AddCallback(callback),
toId,
linkStr,
linkName,
linkCaption,
linkDescription,
pictureStr,
mediaSource);
}
public override void AppEventsLogEvent(
string logEvent,
float? valueToSum,
Dictionary<string, object> parameters)
{
NativeDict dict = MarshallDict(parameters);
if (valueToSum.HasValue)
{
this.iosWrapper.LogAppEvent(logEvent, valueToSum.Value, dict.NumEntries, dict.Keys, dict.Values);
}
else
{
this.iosWrapper.LogAppEvent(logEvent, 0.0, dict.NumEntries, dict.Keys, dict.Values);
}
}
public override void AppEventsLogPurchase(
float logPurchase,
string currency,
Dictionary<string, object> parameters)
{
NativeDict dict = MarshallDict(parameters);
this.iosWrapper.LogPurchaseAppEvent(logPurchase, currency, dict.NumEntries, dict.Keys, dict.Values);
}
public override bool IsImplicitPurchaseLoggingEnabled()
{
return false;
}
public override void ActivateApp(string appId)
{
this.iosWrapper.FBAppEventsActivateApp();
}
public override void FetchDeferredAppLink(FacebookDelegate<IAppLinkResult> callback)
{
this.iosWrapper.FetchDeferredAppLink(this.AddCallback(callback));
}
public override void GetAppLink(
FacebookDelegate<IAppLinkResult> callback)
{
this.iosWrapper.GetAppLink(System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)));
}
public override void OpenFriendFinderDialog(
FacebookDelegate<IGamingServicesFriendFinderResult> callback)
{
this.iosWrapper.OpenFriendFinderDialog(System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)));
}
public override void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void CreateGamingContext(string playerID, FacebookDelegate<ICreateGamingContextResult> callback)
{
this.iosWrapper.CreateGamingContext(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)),
playerID);
}
public override void SwitchGamingContext(string gamingContextID, FacebookDelegate<ISwitchGamingContextResult> callback)
{
this.iosWrapper.SwitchGamingContext(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)),
gamingContextID);
}
public override void ChooseGamingContext(
List<string> filters,
int minSize,
int maxSize,
FacebookDelegate<IChooseGamingContextResult> callback)
{
string filter = "";
if (filters != null && filters.Count > 0)
{
filter = filters[0];
}
this.iosWrapper.ChooseGamingContext(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)),
filter,
minSize,
maxSize);
}
public override void GetCurrentGamingContext(FacebookDelegate<IGetCurrentGamingContextResult> callback)
{
this.iosWrapper.GetCurrentGamingContext(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback))
);
}
public override void GetTournaments(FacebookDelegate<IGetTournamentsResult> callback)
{
this.iosWrapper.GetTournaments(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback))
);
}
public override void UpdateTournament(string tournamentID, int score, FacebookDelegate<ITournamentScoreResult> callback)
{
this.iosWrapper.UpdateTournament(
tournamentID,
score,
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback))
);
}
public override void UpdateAndShareTournament(string tournamentID, int score, FacebookDelegate<IDialogResult> callback)
{
this.iosWrapper.UpdateAndShareTournament(
tournamentID,
score,
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback))
);
}
public override void CreateAndShareTournament(
int initialScore,
string title,
TournamentSortOrder sortOrder,
TournamentScoreFormat scoreFormat,
long endTime,
string payload,
FacebookDelegate<IDialogResult> callback)
{
this.iosWrapper.CreateAndShareTournament(
initialScore,
title,
sortOrder,
scoreFormat,
endTime,
payload,
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback))
);
}
public override void RefreshCurrentAccessToken(
FacebookDelegate<IAccessTokenRefreshResult> callback)
{
this.iosWrapper.RefreshCurrentAccessToken(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)));
}
protected override void SetShareDialogMode(ShareDialogMode mode)
{
this.iosWrapper.SetShareDialogMode((int)mode);
}
public override void UploadImageToMediaLibrary(
string caption,
Uri imageUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
this.iosWrapper.UploadImageToMediaLibrary(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)),
caption,
imageUri.AbsolutePath.ToString(),
shouldLaunchMediaDialog);
}
public override void UploadVideoToMediaLibrary(
string caption,
Uri videoUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
this.iosWrapper.UploadVideoToMediaLibrary(
System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)),
caption,
videoUri.AbsolutePath.ToString());
}
public override void GetUserLocale(FacebookDelegate<ILocaleResult> callback)
{
throw new NotImplementedException();
}
private static IIOSWrapper GetIOSWrapper()
{
Assembly assembly = Assembly.Load("Facebook.Unity.IOS");
Type type = assembly.GetType("Facebook.Unity.IOS.IOSWrapper");
IIOSWrapper iosWrapper = (IIOSWrapper)Activator.CreateInstance(type);
return iosWrapper;
}
private static NativeDict MarshallDict(Dictionary<string, object> dict)
{
NativeDict res = new NativeDict();
if (dict != null && dict.Count > 0)
{
res.Keys = new string[dict.Count];
res.Values = new string[dict.Count];
res.NumEntries = 0;
foreach (KeyValuePair<string, object> kvp in dict)
{
res.Keys[res.NumEntries] = kvp.Key;
res.Values[res.NumEntries] = kvp.Value.ToString();
res.NumEntries++;
}
}
return res;
}
private static NativeDict MarshallDict(Dictionary<string, string> dict)
{
NativeDict res = new NativeDict();
if (dict != null && dict.Count > 0)
{
res.Keys = new string[dict.Count];
res.Values = new string[dict.Count];
res.NumEntries = 0;
foreach (KeyValuePair<string, string> kvp in dict)
{
res.Keys[res.NumEntries] = kvp.Key;
res.Values[res.NumEntries] = kvp.Value;
res.NumEntries++;
}
}
return res;
}
private int AddCallback<T>(FacebookDelegate<T> callback) where T : IResult
{
string asyncId = this.CallbackManager.AddFacebookDelegate(callback);
return Convert.ToInt32(asyncId);
}
private class NativeDict
{
public NativeDict()
{
this.NumEntries = 0;
this.Keys = null;
this.Values = null;
}
public int NumEntries { get; set; }
public string[] Keys { get; set; }
public string[] Values { get; set; }
}
}
}
| 542 |
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.Mobile.IOS
{
internal class IOSFacebookGameObject : MobileFacebookGameObject
{
}
}
| 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.Mobile.IOS
{
internal class IOSFacebookLoader : FB.CompiledFacebookLoader
{
protected override FacebookGameObject FBGameObject
{
get
{
IOSFacebookGameObject iosFB = ComponentFactory.GetComponent<IOSFacebookGameObject>();
if (iosFB.Facebook == null)
{
iosFB.Facebook = new IOSFacebook();
}
return iosFB;
}
}
}
}
| 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.Editor
{
using System;
using System.Collections.Generic;
using Facebook.Unity.Canvas;
using Facebook.Unity.Editor.Dialogs;
using Facebook.Unity.Mobile;
internal class EditorFacebook : FacebookBase, IMobileFacebookImplementation, ICanvasFacebookImplementation
{
private const string WarningMessage = "You are using the facebook SDK in the Unity Editor. " +
"Behavior may not be the same as when used on iOS, Android, or Web.";
private const string AccessTokenKey = "com.facebook.unity.editor.accesstoken";
private IEditorWrapper editorWrapper;
public EditorFacebook(IEditorWrapper wrapper, CallbackManager callbackManager) : base(callbackManager)
{
this.editorWrapper = wrapper;
}
public EditorFacebook() : this(new EditorWrapper(EditorFacebook.EditorGameObject), new CallbackManager())
{
}
public override bool LimitEventUsage { get; set; }
public ShareDialogMode ShareDialogMode { get; set; }
public override string SDKName
{
get
{
return "FBUnityEditorSDK";
}
}
public override string SDKVersion
{
get
{
return Facebook.Unity.FacebookSdkVersion.Build;
}
}
public string UserID { get; set; }
private static IFacebookCallbackHandler EditorGameObject
{
get
{
return ComponentFactory.GetComponent<EditorFacebookGameObject>();
}
}
public override void Init(InitDelegate onInitComplete)
{
// Warn that editor behavior will not match supported platforms
FacebookLogger.Warn(WarningMessage);
base.Init(onInitComplete);
this.editorWrapper.Init();
}
public override void LogInWithReadPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
// For the editor don't worry about the difference between
// LogInWithReadPermissions and LogInWithPublishPermissions
this.LogInWithPublishPermissions(permissions, callback);
}
public override void LogInWithPublishPermissions(
IEnumerable<string> permissions,
FacebookDelegate<ILoginResult> callback)
{
this.editorWrapper.ShowLoginMockDialog(
this.OnLoginComplete,
this.CallbackManager.AddFacebookDelegate(callback),
permissions.ToCommaSeparateList());
}
public void EnableProfileUpdatesOnAccessTokenChange(bool enable)
{
FacebookLogger.Log("Pew! Pretending to enable Profile updates on access token change. Doesn't actually work in the editor");
}
public void LoginWithTrackingPreference(
string tracking,
IEnumerable<string> permissions,
string nonce,
FacebookDelegate<ILoginResult> callback)
{
this.editorWrapper.ShowLoginMockDialog(
this.OnLoginComplete,
this.CallbackManager.AddFacebookDelegate(callback),
permissions.ToCommaSeparateList());
}
public override 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)
{
this.editorWrapper.ShowAppRequestMockDialog(
this.OnAppRequestsComplete,
this.CallbackManager.AddFacebookDelegate(callback));
}
public override void ShareLink(
Uri contentURL,
string contentTitle,
string contentDescription,
Uri photoURL,
FacebookDelegate<IShareResult> callback)
{
this.editorWrapper.ShowMockShareDialog(
this.OnShareLinkComplete,
"ShareLink",
this.CallbackManager.AddFacebookDelegate(callback));
}
public override void FeedShare(
string toId,
Uri link,
string linkName,
string linkCaption,
string linkDescription,
Uri picture,
string mediaSource,
FacebookDelegate<IShareResult> callback)
{
this.editorWrapper.ShowMockShareDialog(
this.OnShareLinkComplete,
"FeedShare",
this.CallbackManager.AddFacebookDelegate(callback));
}
public override void ActivateApp(string appId)
{
FacebookLogger.Log("Pew! Pretending to send this off. Doesn't actually work in the editor");
}
public override void GetAppLink(FacebookDelegate<IAppLinkResult> callback)
{
var result = new Dictionary<string, object>();
result[Constants.UrlKey] = "mockurl://testing.url";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
this.OnGetAppLinkComplete(new ResultContainer(result));
}
public override void AppEventsLogEvent(
string logEvent,
float? valueToSum,
Dictionary<string, object> parameters)
{
FacebookLogger.Log("Pew! Pretending to send this off. Doesn't actually work in the editor");
}
public override void AppEventsLogPurchase(
float logPurchase,
string currency,
Dictionary<string, object> parameters)
{
FacebookLogger.Log("Pew! Pretending to send this off. Doesn't actually work in the editor");
}
public bool IsImplicitPurchaseLoggingEnabled()
{
return true;
}
public void SetAutoLogAppEventsEnabled(bool autoLogAppEventsEnabled)
{
return;
}
public void SetAdvertiserIDCollectionEnabled(bool advertiserIDCollectionEnabled)
{
return;
}
public bool SetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled)
{
return true;
}
public void SetPushNotificationsDeviceTokenString(string token)
{
return;
}
public void SetDataProcessingOptions(IEnumerable<string> options, int country, int state)
{
return;
}
public AuthenticationToken CurrentAuthenticationToken()
{
return null;
}
public override Profile CurrentProfile()
{
return null;
}
public override void CurrentProfile(FacebookDelegate<IProfileResult> callback)
{
throw new NotSupportedException();
}
public void FetchDeferredAppLink(
FacebookDelegate<IAppLinkResult> callback)
{
var result = new Dictionary<string, object>();
result[Constants.UrlKey] = "mockurl://testing.url";
result[Constants.RefKey] = "mock ref";
result[Constants.ExtrasKey] = new Dictionary<string, object>()
{
{
"mock extra key", "mock extra value"
}
};
result[Constants.TargetUrlKey] = "mocktargeturl://mocktarget.url";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
this.OnFetchDeferredAppLinkComplete(new ResultContainer(result));
}
public void Pay(
string product,
string action,
int quantity,
int? quantityMin,
int? quantityMax,
string requestId,
string pricepointId,
string testCurrency,
FacebookDelegate<IPayResult> callback)
{
this.editorWrapper.ShowPayMockDialog(
this.OnPayComplete,
this.CallbackManager.AddFacebookDelegate(callback));
}
public void PayWithProductId(
string productId,
string action,
int quantity,
int? quantityMin,
int? quantityMax,
string requestId,
string pricepointId,
string testCurrency,
FacebookDelegate<IPayResult> callback)
{
this.editorWrapper.ShowPayMockDialog(
this.OnPayComplete,
this.CallbackManager.AddFacebookDelegate(callback));
}
public void PayWithProductId(
string productId,
string action,
string developerPayload,
string testCurrency,
FacebookDelegate<IPayResult> callback)
{
this.editorWrapper.ShowPayMockDialog(
this.OnPayComplete,
this.CallbackManager.AddFacebookDelegate(callback));
}
public void RefreshCurrentAccessToken(
FacebookDelegate<IAccessTokenRefreshResult> callback)
{
if (callback == null)
{
return;
}
var result = new Dictionary<string, object>()
{
{ Constants.CallbackIdKey, this.CallbackManager.AddFacebookDelegate(callback) }
};
if (AccessToken.CurrentAccessToken == null)
{
result[Constants.ErrorKey] = "No current access token";
}
else
{
var accessTokenDic = (IDictionary<string, object>)MiniJSON.Json.Deserialize(
AccessToken.CurrentAccessToken.ToJson());
result.AddAllKVPFrom(accessTokenDic);
}
this.OnRefreshCurrentAccessTokenComplete(new ResultContainer(result));
}
public override void OnAppRequestsComplete(ResultContainer resultContainer)
{
var result = new AppRequestResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void OnGetAppLinkComplete(ResultContainer resultContainer)
{
var result = new AppLinkResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void OnLoginComplete(ResultContainer resultContainer)
{
var result = new LoginResult(resultContainer);
this.OnAuthResponse(result);
}
public override void OnShareLinkComplete(ResultContainer resultContainer)
{
var result = new ShareResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnFetchDeferredAppLinkComplete(ResultContainer resultContainer)
{
var result = new AppLinkResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPayComplete(ResultContainer resultContainer)
{
var result = new PayResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnRefreshCurrentAccessTokenComplete(ResultContainer resultContainer)
{
var result = new AccessTokenRefreshResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnFriendFinderComplete(ResultContainer resultContainer)
{
var result = new GamingServicesFriendFinderResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnUploadImageToMediaLibraryComplete(ResultContainer resultContainer)
{
var result = new MediaUploadResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnUploadVideoToMediaLibraryComplete(ResultContainer resultContainer)
{
var result = new MediaUploadResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnOnIAPReadyComplete(ResultContainer resultContainer)
{
var result = new IAPReadyResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetCatalogComplete(ResultContainer resultContainer)
{
var result = new CatalogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetPurchasesComplete(ResultContainer resultContainer)
{
var result = new PurchasesResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPurchaseComplete(ResultContainer resultContainer)
{
var result = new PurchaseResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnConsumePurchaseComplete(ResultContainer resultContainer)
{
var result = new ConsumePurchaseResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetSubscribableCatalogComplete(ResultContainer resultContainer)
{
var result = new SubscribableCatalogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetSubscriptionsComplete(ResultContainer resultContainer)
{
var result = new SubscriptionsResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPurchaseSubscriptionComplete(ResultContainer resultContainer)
{
var result = new SubscriptionResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnCancelSubscriptionComplete(ResultContainer resultContainer)
{
var result = new CancelSubscriptionResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnInitCloudGameComplete(ResultContainer resultContainer)
{
var result = new InitCloudGameResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGameLoadCompleteComplete(ResultContainer resultContainer)
{
var result = new GameLoadCompleteResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnScheduleAppToUserNotificationComplete(ResultContainer resultContainer)
{
var result = new ScheduleAppToUserNotificationResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnLoadInterstitialAdComplete(ResultContainer resultContainer)
{
var result = new InterstitialAdResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnShowInterstitialAdComplete(ResultContainer resultContainer)
{
var result = new InterstitialAdResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnLoadRewardedVideoComplete(ResultContainer resultContainer)
{
var result = new RewardedVideoResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnShowRewardedVideoComplete(ResultContainer resultContainer)
{
var result = new RewardedVideoResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetPayloadComplete(ResultContainer resultContainer)
{
var result = new PayloadResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPostSessionScoreComplete(ResultContainer resultContainer)
{
var result = new SessionScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnPostTournamentScoreComplete(ResultContainer resultContainer)
{
var result = new TournamentScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnShareTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnCreateTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetTournamentsComplete(ResultContainer resultContainer)
{
var result = new GetTournamentsResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnUpdateTournamentComplete(ResultContainer resultContainer)
{
var result = new TournamentScoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnTournamentDialogSuccess(ResultContainer resultContainer)
{
var result = new TournamentResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnTournamentDialogCancel(ResultContainer resultContainer)
{
var result = new AbortDialogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnTournamentDialogError(ResultContainer resultContainer)
{
var result = new AbortDialogResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnOpenAppStoreComplete(ResultContainer resultContainer)
{
var result = new OpenAppStoreResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnCreateGamingContextComplete(ResultContainer resultContainer)
{
var result = new CreateGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnSwitchGamingContextComplete(ResultContainer resultContainer)
{
var result = new SwitchGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnChooseGamingContextComplete(ResultContainer resultContainer)
{
var result = new ChooseGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public void OnGetCurrentGamingContextComplete(ResultContainer resultContainer)
{
var result = new GetCurrentGamingContextResult(resultContainer);
CallbackManager.OnFacebookResponse(result);
}
public override void OpenFriendFinderDialog(FacebookDelegate<IGamingServicesFriendFinderResult> callback)
{
this.editorWrapper.ShowMockFriendFinderDialog(
this.OnFriendFinderComplete,
"Friend Finder Dialog",
this.CallbackManager.AddFacebookDelegate(callback));
}
public override void GetFriendFinderInvitations(FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void DeleteFriendFinderInvitation(string invitationId, FacebookDelegate<IFriendFinderInvitationResult> callback)
{
throw new NotImplementedException();
}
public override void UploadImageToMediaLibrary(
string caption,
Uri imageUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
var result = new Dictionary<string, object>();
result["id"] = "1232453";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
this.OnFetchDeferredAppLinkComplete(new ResultContainer(result));
}
public override void UploadVideoToMediaLibrary(
string caption,
Uri imageUri,
bool shouldLaunchMediaDialog,
FacebookDelegate<IMediaUploadResult> callback)
{
// construct a dummy ResultContainer
// to pretend we actually did an upload
var result = new Dictionary<string, object>();
result["video_id"] = "456789";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
this.OnFetchDeferredAppLinkComplete(new ResultContainer(result));
}
public override void GetUserLocale(FacebookDelegate<ILocaleResult> callback)
{
throw new NotImplementedException();
}
public void OnIAPReady(FacebookDelegate<IIAPReadyResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void GetCatalog(FacebookDelegate<ICatalogResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "[{\"productID\":\"123\",\"title\":\"item\",\"price\":\"$0.99\",\"priceAmount\":\"0.99\",\"priceCurrencyCode\":\"USD\"}]";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void GetPurchases(FacebookDelegate<IPurchasesResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "[{\"isConsumed\":\"false\",\"paymentID\":\"2607915835989565\",\"productID\":\"123\",\"purchasePlatform\":\"FB\",\"purchaseTime\":\"1583797821\":\"purchaseToken\":\"1655700687901784\",\"signedRequest\":\"abc123ZYZ\"}]";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void Purchase(string productID, FacebookDelegate<IPurchaseResult> callback, string developerPayload = "")
{
var result = new Dictionary<string, object>();
result["success"] = "{\"isConsumed\":\"false\",\"paymentID\":\"2607915835989565\",\"productID\":\"123\",\"purchasePlatform\":\"FB\",\"purchaseTime\":\"1583797821\",\"purchaseToken\":\"1655700687901784\",\"signedRequest\":\"XZZ9xQDHOGulfhZMRVQ8UC-TadAqFrueYveAAqxock.eyJhbGdvcm10aG0iOiJITUFDLVNIQTI1Nilslm...\"}";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void ConsumePurchase(string purchaseToken, FacebookDelegate<IConsumePurchaseResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void GetSubscribableCatalog(FacebookDelegate<ISubscribableCatalogResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "[{\"productID\":\"123\",\"title\":\"item\",\"price\":\"$0.99\",\"priceAmount\":\"0.99\",\"priceCurrencyCode\":\"USD\",\"subscriptionTerm\":\"MONTHLY\"}]";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void GetSubscriptions(FacebookDelegate<ISubscriptionsResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "[{\"deactivationTime\":\"15887857836\",\"isEntitlementActive\":\"true\",\"periodStartTime\":\"1583797821\",\"periodStartTime\":\"1584516124\",\"productID\":\"123\",\"purchasePlatform\":\"FB\",\"purchaseTime\":\"1583797821\":\"purchaseToken\":\"1655700687901784\",\"stats\":\"ACTIVE\",\"signedRequest\":\"abc123ZYZ\",\"subscriptionTerm\":\"MONTHLY\"}]";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void PurchaseSubscription(string productID, FacebookDelegate<ISubscriptionResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "{\"deactivationTime\":\"15887857836\",\"isEntitlementActive\":\"true\",\"periodStartTime\":\"1583797821\",\"periodStartTime\":\"1584516124\",\"productID\":\"123\",\"purchasePlatform\":\"FB\",\"purchaseTime\":\"1583797821\":\"purchaseToken\":\"1655700687901784\",\"stats\":\"ACTIVE\",\"signedRequest\":\"abc123ZYZ\",\"subscriptionTerm\":\"MONTHLY\"}";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void CancelSubscription(string purchaseToken, FacebookDelegate<ICancelSubscriptionResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void InitCloudGame(FacebookDelegate<IInitCloudGameResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void GameLoadComplete(FacebookDelegate<IGameLoadCompleteResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void ScheduleAppToUserNotification(
string title,
string body,
Uri media,
int timeInterval,
string payload,
FacebookDelegate<IScheduleAppToUserNotificationResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void LoadInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void ShowInterstitialAd(string placementID, FacebookDelegate<IInterstitialAdResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void LoadRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void ShowRewardedVideo(string placementID, FacebookDelegate<IRewardedVideoResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void GetPayload(FacebookDelegate<IPayloadResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "{\"key\":\"test\",\"value\":\"123\"}";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void PostSessionScore(int score, FacebookDelegate<ISessionScoreResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void PostTournamentScore(int score, FacebookDelegate<ITournamentScoreResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void GetTournament(FacebookDelegate<ITournamentResult> callback)
{
var result = new Dictionary<string, object>();
result["tournamentId"] = "123";
result["contextId"] = "456";
result["endTime"] = "456";
result["data"] = new Dictionary<string, string>();
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void ShareTournament(int score, Dictionary<string, string> data, FacebookDelegate<ITournamentScoreResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public override void CreateTournament(
int initialScore,
string title,
string imageBase64DataUrl,
string sortOrder,
string scoreFormat,
Dictionary<string, string> data,
FacebookDelegate<ITournamentResult> callback)
{
var result = new Dictionary<string, object>();
result["tournamentId"] = "123";
result["contextId"] = "456";
result["endTime"] = "456";
result["data"] = new Dictionary<string, string>();
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void GetTournaments(FacebookDelegate<IGetTournamentsResult> callback)
{
throw new NotImplementedException();
}
public void UpdateTournament(string tournamentID, int score, FacebookDelegate<ITournamentScoreResult> callback)
{
throw new NotImplementedException();
}
public void UpdateAndShareTournament(string tournamentID, int score, FacebookDelegate<IDialogResult> callback)
{
throw new NotImplementedException();
}
public void CreateAndShareTournament(
int initialScore,
string title,
TournamentSortOrder sortOrder,
TournamentScoreFormat scoreFormat,
long endTime,
string payload,
FacebookDelegate<IDialogResult> callback)
{
throw new NotImplementedException();
}
public void OpenAppStore(FacebookDelegate<IOpenAppStoreResult> callback)
{
var result = new Dictionary<string, object>();
result["success"] = "";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void CreateGamingContext(string playerID, FacebookDelegate<ICreateGamingContextResult> callback)
{
var result = new Dictionary<string, object>();
result["contextId"] = "1234";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void SwitchGamingContext(string gamingContextID, FacebookDelegate<ISwitchGamingContextResult> callback)
{
var result = new Dictionary<string, object>();
result["contextId"] = "1234";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void ChooseGamingContext(List<string> filters, int minSize, int maxSize, FacebookDelegate<IChooseGamingContextResult> callback)
{
var result = new Dictionary<string, object>();
result["contextId"] = "1234";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
public void GetCurrentGamingContext(FacebookDelegate<IGetCurrentGamingContextResult> callback)
{
var result = new Dictionary<string, object>();
result["contextId"] = "1234";
result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback);
}
#region Canvas Dummy Methods
public void OnFacebookAuthResponseChange(ResultContainer resultContainer)
{
throw new NotSupportedException();
}
public void OnUrlResponse(string message)
{
throw new NotSupportedException();
}
public void OnHideUnity(bool hidden)
{
throw new NotSupportedException();
}
#endregion
}
}
| 889 |
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.Editor
{
using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.SceneManagement;
internal class EditorFacebookGameObject : FacebookGameObject
{
protected override void OnAwake()
{
CodelessIAPAutoLog.addListenerToIAPButtons(this);
}
void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
CodelessIAPAutoLog.addListenerToIAPButtons(this);
}
void OnDisable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
public void onPurchaseCompleteHandler(System.Object data) {
CodelessIAPAutoLog.handlePurchaseCompleted(data);
}
}
}
| 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.Editor
{
internal class EditorFacebookLoader : FB.CompiledFacebookLoader
{
protected override FacebookGameObject FBGameObject
{
get
{
EditorFacebookGameObject editorFB = ComponentFactory.GetComponent<EditorFacebookGameObject>();
editorFB.Facebook = new EditorFacebook();
return editorFB;
}
}
}
}
| 36 |
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.Editor
{
using System.Collections.Generic;
using UnityEngine;
internal abstract class EditorFacebookMockDialog : MonoBehaviour
{
private Rect modalRect;
private GUIStyle modalStyle;
public Utilities.Callback<ResultContainer> Callback { protected get; set; }
public string CallbackID { protected get; set; }
protected abstract string DialogTitle { get; }
public void Start()
{
this.modalRect = new Rect(10, 10, Screen.width - 20, Screen.height - 20);
Texture2D texture = new Texture2D(1, 1);
texture.SetPixel(0, 0, new Color(0.2f, 0.2f, 0.2f, 1.0f));
texture.Apply();
this.modalStyle = new GUIStyle();
this.modalStyle.normal.background = texture;
}
public void OnGUI()
{
GUI.Window(
this.GetHashCode(),
this.modalRect,
this.OnGUIDialog,
this.DialogTitle,
this.modalStyle);
}
protected abstract void DoGui();
protected abstract void SendSuccessResult();
protected virtual void SendCancelResult()
{
var dictionary = new Dictionary<string, object>();
dictionary[Constants.CancelledKey] = true;
if (!string.IsNullOrEmpty(this.CallbackID))
{
dictionary[Constants.CallbackIdKey] = this.CallbackID;
}
this.Callback(new ResultContainer(dictionary.ToJson()));
}
protected virtual void SendErrorResult(string errorMessage)
{
var dictionary = new Dictionary<string, object>();
dictionary[Constants.ErrorKey] = errorMessage;
if (!string.IsNullOrEmpty(this.CallbackID))
{
dictionary[Constants.CallbackIdKey] = this.CallbackID;
}
this.Callback(new ResultContainer(dictionary.ToJson()));
}
private void OnGUIDialog(int windowId)
{
GUILayout.Space(10);
GUILayout.BeginVertical();
GUILayout.Label("Warning! Mock dialog responses will NOT match production dialogs");
GUILayout.Label("Test your app on one of the supported platforms");
this.DoGui();
GUILayout.EndVertical();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
var loginLabel = new GUIContent("Send Success");
var buttonRect = GUILayoutUtility.GetRect(loginLabel, GUI.skin.button);
if (GUI.Button(buttonRect, loginLabel))
{
this.SendSuccessResult();
MonoBehaviour.Destroy(this);
}
var cancelLabel = new GUIContent("Send Cancel");
var cancelButtonRect = GUILayoutUtility.GetRect(cancelLabel, GUI.skin.button);
if (GUI.Button(cancelButtonRect, cancelLabel, GUI.skin.button))
{
this.SendCancelResult();
MonoBehaviour.Destroy(this);
}
var errorLabel = new GUIContent("Send Error");
var errorButtonRect = GUILayoutUtility.GetRect(cancelLabel, GUI.skin.button);
if (GUI.Button(errorButtonRect, errorLabel, GUI.skin.button))
{
this.SendErrorResult("Error: Error button pressed");
MonoBehaviour.Destroy(this);
}
GUILayout.EndHorizontal();
}
}
}
| 124 |
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.Editor
{
using Facebook.Unity.Editor.Dialogs;
internal class EditorWrapper : IEditorWrapper
{
private IFacebookCallbackHandler callbackHandler;
public EditorWrapper(IFacebookCallbackHandler callbackHandler)
{
this.callbackHandler = callbackHandler;
}
public void Init()
{
this.callbackHandler.OnInitComplete(string.Empty);
}
public void ShowLoginMockDialog(
Utilities.Callback<ResultContainer> callback,
string callbackId,
string permsisions)
{
var dialog = ComponentFactory.GetComponent<MockLoginDialog>();
dialog.Callback = callback;
dialog.CallbackID = callbackId;
}
public void ShowAppRequestMockDialog(
Utilities.Callback<ResultContainer> callback,
string callbackId)
{
this.ShowEmptyMockDialog(callback, callbackId, "Mock App Request");
}
public void ShowPayMockDialog(
Utilities.Callback<ResultContainer> callback,
string callbackId)
{
this.ShowEmptyMockDialog(callback, callbackId, "Mock Pay");
}
public void ShowMockShareDialog(
Utilities.Callback<ResultContainer> callback,
string subTitle,
string callbackId)
{
var dialog = ComponentFactory.GetComponent<MockShareDialog>();
dialog.SubTitle = subTitle;
dialog.Callback = callback;
dialog.CallbackID = callbackId;
}
public void ShowMockFriendFinderDialog(
Utilities.Callback<ResultContainer> callback,
string subTitle,
string callbackId)
{
this.ShowEmptyMockDialog(callback, callbackId, subTitle);
}
private void ShowEmptyMockDialog(
Utilities.Callback<ResultContainer> callback,
string callbackId,
string title)
{
var dialog = ComponentFactory.GetComponent<EmptyMockDialog>();
dialog.Callback = callback;
dialog.CallbackID = callbackId;
dialog.EmptyDialogTitle = title;
}
}
}
| 94 |
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.Editor
{
internal interface IEditorWrapper
{
void Init();
void ShowLoginMockDialog(
Utilities.Callback<ResultContainer> callback,
string callbackId,
string permissions);
void ShowAppRequestMockDialog(
Utilities.Callback<ResultContainer> callback,
string callbackId);
void ShowPayMockDialog(
Utilities.Callback<ResultContainer> callback,
string callbackId);
void ShowMockShareDialog(
Utilities.Callback<ResultContainer> callback,
string subTitle,
string callbackId);
void ShowMockFriendFinderDialog(
Utilities.Callback<ResultContainer> callback,
string subTitle,
string callbackId);
}
}
| 51 |
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.Editor.Dialogs
{
using System.Collections.Generic;
internal class EmptyMockDialog : EditorFacebookMockDialog
{
public string EmptyDialogTitle { get; set; }
protected override string DialogTitle
{
get
{
return this.EmptyDialogTitle;
}
}
protected override void DoGui()
{
// Empty
}
protected override void SendSuccessResult()
{
var result = new Dictionary<string, object>();
result["did_complete"] = true;
if (!string.IsNullOrEmpty(this.CallbackID))
{
result[Constants.CallbackIdKey] = this.CallbackID;
}
if (this.Callback != null)
{
this.Callback(new ResultContainer(result));
}
}
}
}
| 58 |
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.Editor.Dialogs
{
using System;
using System.Collections.Generic;
using UnityEngine;
internal class MockLoginDialog : EditorFacebookMockDialog
{
private string accessToken = string.Empty;
protected override string DialogTitle
{
get
{
return "Mock Login Dialog";
}
}
protected override void DoGui()
{
GUILayout.BeginHorizontal();
GUILayout.Label("User Access Token:");
this.accessToken = GUILayout.TextField(this.accessToken, GUI.skin.textArea, GUILayout.MinWidth(400));
GUILayout.EndHorizontal();
GUILayout.Space(10);
if (GUILayout.Button("Find Access Token"))
{
Application.OpenURL(string.Format("https://developers.facebook.com/tools/accesstoken/?app_id={0}", FB.AppId));
}
GUILayout.Space(20);
}
protected override void SendSuccessResult()
{
if (string.IsNullOrEmpty(this.accessToken))
{
this.SendErrorResult("Empty Access token string");
return;
}
// This whole module does a bunch of Graph API calls to simulate the
// reponse from an actual Login. It then constructs the Result Object to
// send over to the SDK to construct an AccessToken object. In order to honor
// the correct domain while doing this, we will construct a dummy access token so
// that FB.API() can determine the right domain to send the request to. Once this method
// returns the real AccessToken object will be constructed and will replace this dummy one.
List<string> dummyPerms = new List<string>();
dummyPerms.Add("public_profile");
string graphDomain = this.accessToken.StartsWith("GG") ? "gaming" : "facebook";
AccessToken tmpAccessToken = new AccessToken(
this.accessToken,
"me",
DateTime.UtcNow.AddDays(60),
dummyPerms,
DateTime.UtcNow,
graphDomain);
AccessToken.CurrentAccessToken = tmpAccessToken;
// Make a Graph API call to get FBID
FB.API(
"/me?fields=id",
HttpMethod.GET,
delegate(IGraphResult graphResult)
{
if (!string.IsNullOrEmpty(graphResult.Error))
{
this.SendErrorResult("Graph API error: " + graphResult.Error);
return;
}
string facebookID = graphResult.ResultDictionary["id"] as string;
// Make a Graph API call to get Permissions
FB.API(
"/me/permissions",
HttpMethod.GET,
delegate(IGraphResult permResult)
{
if (!string.IsNullOrEmpty(permResult.Error))
{
this.SendErrorResult("Graph API error: " + permResult.Error);
return;
}
// Parse permissions
List<string> grantedPerms = new List<string>();
List<string> declinedPerms = new List<string>();
var data = permResult.ResultDictionary["data"] as List<object>;
foreach (Dictionary<string, object> dict in data)
{
if (dict["status"] as string == "granted")
{
grantedPerms.Add(dict["permission"] as string);
}
else
{
declinedPerms.Add(dict["permission"] as string);
}
}
// Create Access Token
var newToken = new AccessToken(
this.accessToken,
facebookID,
DateTime.UtcNow.AddDays(60),
grantedPerms,
DateTime.UtcNow,
graphDomain);
var result = (IDictionary<string, object>)MiniJSON.Json.Deserialize(newToken.ToJson());
result.Add("granted_permissions", grantedPerms);
result.Add("declined_permissions", declinedPerms);
if (!string.IsNullOrEmpty(this.CallbackID))
{
result[Constants.CallbackIdKey] = this.CallbackID;
}
if (this.Callback != null)
{
this.Callback(new ResultContainer(result));
}
});
});
}
}
}
| 149 |
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.Editor.Dialogs
{
using System.Collections.Generic;
using System.Text;
internal class MockShareDialog : EditorFacebookMockDialog
{
public string SubTitle { private get; set; }
protected override string DialogTitle
{
get
{
return "Mock " + this.SubTitle + " Dialog";
}
}
protected override void DoGui()
{
// Empty
}
protected override void SendSuccessResult()
{
var result = new Dictionary<string, object>();
if (FB.IsLoggedIn)
{
result["postId"] = this.GenerateFakePostID();
}
else
{
result["did_complete"] = true;
}
if (!string.IsNullOrEmpty(this.CallbackID))
{
result[Constants.CallbackIdKey] = this.CallbackID;
}
if (this.Callback != null)
{
this.Callback(new ResultContainer(result));
}
}
protected override void SendCancelResult()
{
var result = new Dictionary<string, object>();
result[Constants.CancelledKey] = "true";
if (!string.IsNullOrEmpty(this.CallbackID))
{
result[Constants.CallbackIdKey] = this.CallbackID;
}
this.Callback(new ResultContainer(result));
}
private string GenerateFakePostID()
{
StringBuilder sb = new StringBuilder();
sb.Append(AccessToken.CurrentAccessToken.UserId);
sb.Append('_');
for (int i = 0; i < 17; i++)
{
sb.Append(UnityEngine.Random.Range(0, 10));
}
return sb.ToString();
}
}
}
| 93 |
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.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("16.0.1")]
[assembly: InternalsVisibleTo("Assembly-CSharp")]
[assembly: InternalsVisibleTo("Facebook.Unity.Android")]
[assembly: InternalsVisibleTo("Facebook.Unity.Canvas")]
[assembly: InternalsVisibleTo("Facebook.Unity.IOS")]
[assembly: InternalsVisibleTo("Facebook.Unity.Tests")]
[assembly: InternalsVisibleTo("Facebook.Unity.Windows")]
| 31 |
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;
using System.Text;
internal class AbortDialogResult : ResultBase, IDialogResult
{
internal AbortDialogResult(ResultContainer resultContainer) : base(resultContainer)
{
this.Success = false;
}
public bool Success { get; private set; }
}
}
| 36 |
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 class AccessTokenRefreshResult : ResultBase, IAccessTokenRefreshResult
{
public AccessTokenRefreshResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null && this.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey))
{
this.AccessToken = Utilities.ParseAccessTokenFromResult(this.ResultDictionary);
}
}
public AccessToken AccessToken { get; private set; }
public override string ToString()
{
return Utilities.FormatToString(
base.ToString(),
this.GetType().Name,
new Dictionary<string, string>()
{
{ "AccessToken", this.AccessToken.ToStringNullOk() },
});
}
}
}
| 49 |
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 class AppLinkResult : ResultBase, IAppLinkResult
{
public AppLinkResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
string url;
if (this.ResultDictionary.TryGetValue<string>(Constants.UrlKey, out url))
{
this.Url = url;
}
string targetUrl;
if (this.ResultDictionary.TryGetValue<string>(Constants.TargetUrlKey, out targetUrl))
{
this.TargetUrl = targetUrl;
}
string refStr;
if (this.ResultDictionary.TryGetValue<string>(Constants.RefKey, out refStr))
{
this.Ref = refStr;
}
IDictionary<string, object> argumentBundle;
if (this.ResultDictionary.TryGetValue<IDictionary<string, object>>(Constants.ExtrasKey, out argumentBundle))
{
this.Extras = argumentBundle;
}
}
}
public string Url { get; private set; }
public string TargetUrl { get; private set; }
public string Ref { get; private set; }
public IDictionary<string, object> Extras { get; private set; }
public override string ToString()
{
return Utilities.FormatToString(
base.ToString(),
this.GetType().Name,
new Dictionary<string, string>()
{
{ "Url", this.Url },
{ "TargetUrl", this.TargetUrl },
{ "Ref", this.Ref },
{ "Extras", this.Extras.ToJson() },
});
}
}
}
| 80 |
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 class AppRequestResult : ResultBase, IAppRequestResult
{
public const string RequestIDKey = "request";
public const string ToKey = "to";
public AppRequestResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
string requestID;
if (this.ResultDictionary.TryGetValue(AppRequestResult.RequestIDKey, out requestID))
{
this.RequestID = requestID;
}
string toStr;
if (this.ResultDictionary.TryGetValue(AppRequestResult.ToKey, out toStr))
{
this.To = toStr.Split(',');
}
else
{
// On iOS the to field is an array of IDs
IEnumerable<object> toArray;
if (this.ResultDictionary.TryGetValue(AppRequestResult.ToKey, out toArray))
{
var toList = new List<string>();
foreach (object toEntry in toArray)
{
var toID = toEntry as string;
if (toID != null)
{
toList.Add(toID);
}
}
this.To = toList;
}
}
}
}
public string RequestID { get; private set; }
public IEnumerable<string> To { get; private set; }
public override string ToString()
{
return Utilities.FormatToString(
base.ToString(),
this.GetType().Name,
new Dictionary<string, string>()
{
{ "RequestID", this.RequestID },
{ "To", this.To != null ? this.To.ToCommaSeparateList() : null },
});
}
}
}
| 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.Collections.Generic;
internal class CancelSubscriptionResult : ResultBase, ICancelSubscriptionResult
{
internal CancelSubscriptionResult(ResultContainer resultContainer) : base(resultContainer)
{
}
}
}
| 32 |
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;
using System.Text;
internal class CatalogResult : ResultBase, ICatalogResult
{
public CatalogResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null && this.ResultDictionary.ContainsKey("success"))
{
this.Products = Utilities.ParseCatalogFromResult(this.ResultDictionary);
}
else if (this.ResultDictionary != null && this.ResultDictionary.ContainsKey("products"))
{
this.ResultDictionary.TryGetValue("products", out object productsList);
this.Products = (IList<Product>)productsList;
}
}
public IList<Product> Products { get; private set; }
public override string ToString()
{
StringBuilder sb = new StringBuilder();
foreach (var product in this.Products)
{
sb.AppendLine(product.ToString());
}
return Utilities.FormatToString(
null,
this.GetType().Name,
new Dictionary<string, string>()
{
{ "Products", sb.ToString() },
});
}
}
}
| 61 |
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 class ChooseGamingContextResult : ResultBase, IChooseGamingContextResult
{
internal ChooseGamingContextResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
string contextId;
if (this.ResultDictionary.TryGetValue<string>("contextId", out contextId))
{
this.ContextId = contextId;
}
}
}
public string ContextId { get; private set; }
public override string ToString()
{
return Utilities.FormatToString(
base.ToString(),
this.GetType().Name,
new Dictionary<string, string>()
{
{ "ContextId", this.ContextId },
});
}
}
}
| 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
{
using System.Collections.Generic;
internal class ConsumePurchaseResult : ResultBase, IConsumePurchaseResult
{
internal ConsumePurchaseResult(ResultContainer resultContainer) : base(resultContainer)
{
}
}
}
| 32 |
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 class CreateGamingContextResult : ResultBase, ICreateGamingContextResult
{
internal CreateGamingContextResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
string contextId;
if (this.ResultDictionary.TryGetValue<string>("contextId", out contextId))
{
this.ContextId = contextId;
}
}
}
public string ContextId { get; private set; }
public override string ToString()
{
return Utilities.FormatToString(
base.ToString(),
this.GetType().Name,
new Dictionary<string, string>()
{
{ "ContextId", this.ContextId },
});
}
}
}
| 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
{
using System.Collections.Generic;
internal class FriendFinderInvitationResult : ResultBase, IFriendFinderInvitationResult
{
public const string InvitationsKey = "friends_invitations";
internal FriendFinderInvitationResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
if (this.ResultDictionary.TryGetValue(InvitationsKey, out IList<FriendFinderInviation> inviationsData))
{
this.Invitations = inviationsData;
}
else
{
this.Invitations = null;
}
}
}
public IList<FriendFinderInviation> Invitations { get; private set; }
}
}
| 47 |
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 class GameLoadCompleteResult : ResultBase, IGameLoadCompleteResult
{
internal GameLoadCompleteResult(ResultContainer resultContainer) : base(resultContainer)
{
}
}
}
| 32 |
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 class GamingServicesFriendFinderResult : ResultBase, IGamingServicesFriendFinderResult
{
internal GamingServicesFriendFinderResult(ResultContainer resultContainer) : base(resultContainer)
{
}
}
}
| 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.Collections.Generic;
internal class GetCurrentGamingContextResult : ResultBase, IGetCurrentGamingContextResult
{
internal GetCurrentGamingContextResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
string contextId;
if (this.ResultDictionary.TryGetValue<string>("contextId", out contextId))
{
this.ContextId = contextId;
}
}
}
public string ContextId { get; private set; }
public override string ToString()
{
return Utilities.FormatToString(
base.ToString(),
this.GetType().Name,
new Dictionary<string, string>()
{
{ "ContextId", this.ContextId },
});
}
}
}
| 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
{
using System;
using System.Collections.Generic;
using System.Text;
internal class GetTournamentsResult : ResultBase, IGetTournamentsResult
{
internal GetTournamentsResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
List<TournamentResult> tournaments = new List<TournamentResult>();
foreach(KeyValuePair<string, object> pair in this.ResultDictionary)
{
var dictionary = pair.Value as IDictionary<string, object>;
if (dictionary != null)
{
tournaments.Add(new TournamentResult(new ResultContainer(dictionary)));
}
}
this.Tournaments = tournaments.ToArray();
}
}
public TournamentResult[] Tournaments { get; private set; }
}
}
| 49 |
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.
*/
#pragma warning disable 618
namespace Facebook.Unity
{
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
internal class GraphResult : ResultBase, IGraphResult
{
internal GraphResult(UnityWebRequestAsyncOperation result) :
base(new ResultContainer(result.webRequest.downloadHandler.text), result.webRequest.error, false)
{
this.Init(this.RawResult);
// The WWW object will throw an exception if accessing the texture field and
// an error has occured.
if (string.IsNullOrEmpty(result.webRequest.error))
{
// The Graph API does not return textures directly, but a few endpoints can
// redirect to images when no 'redirect=false' parameter is specified. Ex: '/me/picture'
this.Texture = new Texture2D(2, 2);
this.Texture.LoadImage(result.webRequest.downloadHandler.data);
}
}
public IList<object> ResultList { get; private set; }
public Texture2D Texture { get; private set; }
private void Init(string rawResult)
{
if (string.IsNullOrEmpty(rawResult))
{
return;
}
object serailizedResult = MiniJSON.Json.Deserialize(this.RawResult);
var jsonObject = serailizedResult as IDictionary<string, object>;
if (jsonObject != null)
{
this.ResultDictionary = jsonObject;
return;
}
var jsonArray = serailizedResult as IList<object>;
if (jsonArray != null)
{
this.ResultList = jsonArray;
return;
}
}
}
}
#pragma warning restore 618
| 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.Collections.Generic;
internal class GroupCreateResult : ResultBase, IGroupCreateResult
{
public const string IDKey = "id";
public GroupCreateResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
string groupId;
if (this.ResultDictionary.TryGetValue<string>(GroupCreateResult.IDKey, out groupId))
{
this.GroupId = groupId;
}
}
}
public string GroupId { get; private set; }
public override string ToString()
{
return Utilities.FormatToString(
base.ToString(),
this.GetType().Name,
new Dictionary<string, string>()
{
{ "GroupId", this.GroupId },
});
}
}
}
| 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
{
internal class GroupJoinResult : ResultBase, IGroupJoinResult
{
internal GroupJoinResult(ResultContainer resultContainer) : base(resultContainer)
{
}
}
}
| 30 |
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 class HasLicenseResult : ResultBase, IHasLicenseResult
{
public HasLicenseResult(ResultContainer resultContainer) : base(resultContainer)
{
if (this.ResultDictionary != null)
{
bool hasLicense;
if (this.ResultDictionary.TryGetValue<bool> (Constants.HasLicenseKey, out hasLicense)) {
this.HasLicense = hasLicense;
}
}
}
public bool HasLicense { get; private set; }
}
}
| 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
{
/// <summary>
/// The access token refresh result.
/// </summary>
public interface IAccessTokenRefreshResult : IResult
{
/// <summary>
/// Gets the refreshed access token.
/// </summary>
/// <value>The access token.</value>
AccessToken AccessToken { get; }
}
}
| 35 |
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;
/// <summary>
/// A result containing an app link.
/// </summary>
public interface IAppLinkResult : IResult
{
/// <summary>
/// Gets the URL. This is the url that was used to open the app on iOS
/// or on Android the intent's data string. When handling deffered app
/// links on Android this may not be available.
/// </summary>
/// <value>The link url.</value>
string Url { get; }
/// <summary>
/// Gets the target URI.
/// </summary>
/// <value>The target uri for this App Link.</value>
string TargetUrl { get; }
/// <summary>
/// Gets the ref.
/// </summary>
/// <value> Returns the ref for this App Link.
/// The referer data associated with the app link.
/// This will contain Facebook specific information like fb_access_token, fb_expires_in, and fb_ref.
/// </value>
string Ref { get; }
/// <summary>
/// Gets the extras.
/// </summary>
/// <value>
/// The full set of arguments for this app link. Properties like target uri & ref are typically
/// picked out of this set of arguments.
/// </value>
IDictionary<string, object> Extras { get; }
}
}
| 63 |
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;
/// <summary>
/// App request result.
/// </summary>
public interface IAppRequestResult : IResult
{
/// <summary>
/// Gets RequestID.
/// </summary>
/// <value>A request ID assigned by Facebook.</value>
string RequestID { get; }
/// <summary>
/// Gets the list of users who the request was sent to.
/// </summary>
/// <value>An array of string, each element being the Facebook ID of one of the selected recipients.</value>
IEnumerable<string> To { get; }
}
}
| 43 |
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 class IAPReadyResult : ResultBase, IIAPReadyResult
{
internal IAPReadyResult(ResultContainer resultContainer) : base(resultContainer)
{
}
}
}
| 32 |
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 interface ICancelSubscriptionResult : IResult
{
}
}
| 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.Collections.Generic;
/// <summary>
/// The catalog result.
/// </summary>
public interface ICatalogResult : IResult
{
/// <summary>
/// Gets a list of products available for purchase.
/// </summary>
/// <value>The list of product objects.</value>
IList<Product> Products { get; }
}
}
| 37 |
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>
/// The Choose Gaming Context API result.
/// </summary>
public interface IChooseGamingContextResult : IResult
{
}
} | 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.Collections.Generic;
public interface IConsumePurchaseResult : IResult
{
}
}
| 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
{
/// <summary>
/// The Create Gaming Context API result.
/// </summary>
public interface ICreateGamingContextResult : IResult
{
}
} | 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.Collections.Generic;
/// <summary>
/// The dialog result.
/// </summary>
public interface IDialogResult : IResult
{
}
}
| 32 |