/// <summary>
 ///A convenience method has been provided to log real-money in-app purchases, which is the most common use of event logging.
 /// </summary>
 /// <param name="logPurchase">The name of the event to log</param>
 /// <param name="currency">ISO currency code e.g "USD" </param>
 /// <param name="parameters">Any parameters needed to describe the event </param>
 public static void LogPurchase(float logPurchase, string currency = null, Dictionary <string, object> parameters = null)
 {
     if (!SA_FB.IsInitialized)
     {
         Debug.LogError("SA_FB_Analytics: LogPurchase was skipped Facebook SDK not initialized. " +
                        "Make sure you initialized Facebook SDK on your application start.");
         return;
     }
     SA_FB_Proxy.LogPurchase(logPurchase, currency, parameters);
 }
 /// <summary>
 /// Publishes an App Event. App Events allow you to measure the effectiveness of your Facebook app ads and better understand
 /// the makeup of users engaging with your app. You can use one of 14 predefined events such as 'level achieved', or use custom
 /// events you define.
 ///
 /// Log events that could help you understand player behavior and measure engagement coming from your App Ads on Facebook.
 /// How often these events occur is reported in aggregate with through Facebook Analytics for Apps.
 /// <para> <see cref="https://developers.facebook.com/docs/analytics"/> for information </para>
 ///
 /// Note: Users do not need to be logged in with Facebook in order for you to log App Events.
 /// Note: Predefined events in Facebook.Unity.AppEventName
 /// </summary>
 /// <param name="logEvent">The name of the event to log</param>
 /// <param name="valueToSum">A number representing a 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)
 {
     if (!SA_FB.IsInitialized)
     {
         Debug.LogError("SA_FB_Analytics: " + logEvent + " was skipped Facebook SDK not initialized. " +
                        "Make sure you initialized Facebook SDK on your application start.");
         return;
     }
     SA_FB_Proxy.LogAppEvent(logEvent, valueToSum, parameters);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the state of the Facebook SDK, and initializes all platform-specific data structures and behaviors.
 /// This function can only be called once during the lifetime of the object; later calls lead to undefined behavior.
 ///
 /// Also <see cref="FB.ActivateApp()"/> method will be callend automaticly when initialization is completed
 /// </summary>
 /// <param name="appId">The Facebook application ID of the initializing app. </param>
 /// <param name="clientToken">Client Token</param>
 /// <param name="cookie">Sets a cookie which your server-side code can use to validate a user's Facebook session</param>
 /// <param name="logging">If true, outputs a verbose log to the Javascript console to facilitate debugging. Effective on Web only.</param>
 /// <param name="status">If true, attempts to initialize the Facebook object with valid session data.*</param>
 /// <param name="xfbml">If true, Facebook will immediately parse any XFBML elements on the Facebook Canvas page hosting the app, like the page plugin. Effective on Web only.</param>
 /// <param name="frictionlessRequests">Frictionless Requests</param>
 /// <param name="authResponse">effective in Web Player only, rarely used A Facebook auth_response you have cached to preserve a session, represented in JSON. If an auth_response is provided, FB will initialize itself using the data from that session, with no additional checks.</param>
 /// <param name="javascriptSDKLocale">javascript SDK Locale</param>
 /// <param name="onHideUnity">A function that will be called when Facebook tries to display HTML content within the boundaries of the Canvas. 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>
 /// <param name="onInitComplete">A function that will be called once all data structures in the SDK are initialized; any code that should synchronize with the player's Facebook session should be in onInitComplete().</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 = "en_US", HideUnityDelegate onHideUnity = null, InitDelegate onInitComplete = null)
 {
     SA_FB_Proxy.Init(appId, clientToken, cookie, logging, status, xfbml, frictionlessRequests, authResponse, javascriptSDKLocale, onHideUnity, () =>
     {
         SA_FB_Proxy.ActivateApp();
         if (onInitComplete != null)
         {
             onInitComplete.Invoke();
         }
     });
 }
Exemplo n.º 4
0
 /// <summary>
 /// Makes a call to the Graph API to get data, or take action on a user's behalf.
 /// This will always be used once a user is logged in, and an access token has been granted;
 /// the permissions encoded by the access token determine which Graph API calls will be available.
 ///
 /// This method will automatically check user active session, and if user isn't logged in,
 /// SDK Init & User Login attempt would be made using the editor SDK settings
 /// </summary>
 /// <param name="query">The Graph API endpoint to call. e.g. /me/scores </param>
 /// <param name="method">The HTTP method to use in the call </param>
 /// <param name="callback">A delegate which will receive the result of the call </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)
 {
     SA_FB_LoginUtil.ConfirmLoginStatus((statusResult) =>
     {
         if (statusResult.IsSucceeded)
         {
             SA_FB_Proxy.API(query, method, callback, formData);
         }
         else
         {
             if (callback != null)
             {
                 callback.Invoke(statusResult);
             }
         }
     });
 }
Exemplo n.º 5
0
 /// <summary>
 /// Prompts the user to authorize your application using the Login Dialog appropriate to the platform.
 /// If the user is already logged in and has authorized your application,
 /// checks whether all permissions in the permissions parameter have been granted, and if not,
 /// prompts the user for any that are newly requested.
 ///
 /// In the Unity Editor, a stub function is called, which will prompt you to provide an access token
 /// </summary>
 /// <param name="callback">A delegate that will be called with the result of the Login Dialog </param>
 /// <param name="scopes">A list of Facebook permissions requested from the user </param>
 private static void Login(List <string> scopes, Action <SA_FB_LoginResult> callback)
 {
     if (!scopes.Contains(SA_FB_Permissions.publish_actions.ToString()))
     {
         SA_FB_Proxy.LogInWithReadPermissions(scopes, (loginResult) => {
             var result = new SA_FB_LoginResult(loginResult);
             callback.Invoke(result);
         });
     }
     else
     {
         SA_FB_Proxy.LogInWithPublishPermissions(scopes, (loginResult) => {
             var result = new SA_FB_LoginResult(loginResult);
             callback.Invoke(result);
         });
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the state of the Facebook SDK, and initializes all platform-specific data structures and behaviors.
        /// This function can only be called once during the lifetime of the object; later calls lead to undefined behavior.
        /// Relies on properties that are set in the Unity Editor using the Facebook | Edit settings menu option,
        ///
        /// Also <see cref="FB.ActivateApp()"/> method will be callend automaticly when initialization is completed
        /// </summary>
        /// <param name="onInitComplete">A function that will be called once all data structures in the SDK are initialized; any code that should synchronize with the player's Facebook session should be in onInitComplete().</param>
        /// <param name="onHideUnity">A function that will be called when Facebook tries to display HTML content within the boundaries of the Canvas. 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>
        /// <param name="authResponse">effective in Web Player only, rarely used A Facebook auth_response you have cached to preserve a session, represented in JSON. If an auth_response is provided, FB will initialize itself using the data from that session, with no additional checks.</param>
        public static void Init(InitDelegate onInitComplete = null, HideUnityDelegate onHideUnity = null, string authResponse = null)
        {
            if (s_isInitializing)
            {
                if (onInitComplete != null)
                {
                    s_initCallback += onInitComplete;
                }
                return;
            }

            s_isInitializing = true;
            SA_FB_Proxy.Init(() => {
                SA_FB_Proxy.ActivateApp();
                s_initCallback += onInitComplete;
                s_initCallback.Invoke();
            }, onHideUnity, authResponse);
        }
Exemplo n.º 7
0
 /// <summary>
 /// On Web, this method will log the user out of both your site and Facebook.
 /// On iOS and Android, it will log the user out of your Application.
 /// On all the platforms it will also invalidate any access token that you have for the user that was issued before the logout.
 ///
 /// On Web, you almost certainly should not use this function, which is provided primarily for completeness.
 /// Having a logout control inside a game that executes a Facebook-wide logout will violate users' expectations.
 /// Instead, allow users to control their logged-in status on Facebook itself.
 /// </summary>
 public static void LogOut()
 {
     CurrentUser = null;
     SA_FB_Proxy.LogOut();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Set's the Facebook App Id, the same operation can be made using the editor settings
 /// </summary>
 /// <param name="appId"></param>
 public void SetAppId(string appId)
 {
     SA_FB_Proxy.SetAppId(appId);
 }