ActivityFacebookEngagement.cs 1007 B

1234567891011121314151617181920212223242526272829303132333435
  1. using Facebook.Unity;
  2. using UnityEngine;
  3. /// <summary>
  4. /// In-game Facebook funnel events. Stored in PlayerPrefs so Reset Save does not clear them.
  5. /// </summary>
  6. public static class ActivityFacebookEngagement
  7. {
  8. const string FirstLobbyReportedKey = "CrazyFruit.Activity.FirstLobbyReported";
  9. public static void TryReportFirstLobbyEntry()
  10. {
  11. if (PlayerPrefs.GetInt(FirstLobbyReportedKey, 0) != 0)
  12. return;
  13. if (!FB.IsInitialized)
  14. return;
  15. ActivityFacebookService.LogEvent("completeregistration", 0f);
  16. ActivityFacebookService.LogEvent("addtowishlist", 0f);
  17. PlayerPrefs.SetInt(FirstLobbyReportedKey, 1);
  18. PlayerPrefs.Save();
  19. }
  20. public static void ReportShopPurchase(int priceCoins)
  21. {
  22. if (!FB.IsInitialized)
  23. return;
  24. float value = Mathf.Max(0, priceCoins);
  25. ActivityFacebookService.LogEvent("addtocart", value);
  26. ActivityFacebookService.LogEvent("purchased", value);
  27. }
  28. }