Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. using UnityEngine;
  2. using Heyzap;
  3.  
  4. public class AdManager : MonoBehaviour {
  5.  
  6. public static void InitAds() {
  7. //TODO check if player disabled ads
  8. //TODO check internet connection?
  9. HeyzapAds.Start("55465uyhgff456uyjhgbfr456", HeyzapAds.FLAG_NO_OPTIONS);
  10. HZIncentivizedAd.Fetch();
  11. }
  12.  
  13. public static void HandleAdStatuses(string adState, string adTag) {
  14. Debug.Log("heyzap: " + adState);
  15. if (adState.Equals("show")) {
  16. // Sent when an ad has been displayed.
  17. // This is a good place to pause your app, if applicable.
  18. }
  19. if (adState.Equals("hide")) {
  20. // Sent when an ad has been removed from view.
  21. // This is a good place to unpause your app, if applicable.
  22. }
  23. if (adState.Equals("click")) {
  24. // Sent when an ad has been clicked by the user.
  25. }
  26. if (adState.Equals("failed")) {
  27. // Sent when you call `show`, but there isn't an ad to be shown.
  28. // Some of the possible reasons for show errors:
  29. // - `HeyzapAds.PauseExpensiveWork()` was called, which pauses
  30. // expensive operations like SDK initializations and ad
  31. // fetches, andand `HeyzapAds.ResumeExpensiveWork()` has not
  32. // yet been called
  33. // - The given ad tag is disabled (see your app's Publisher
  34. // Settings dashboard)
  35. // - An ad is already showing
  36. // - A recent IAP is blocking ads from being shown (see your
  37. // app's Publisher Settings dashboard)
  38. // - One or more of the segments the user falls into are
  39. // preventing an ad from being shown (see your Segmentation
  40. // Settings dashboard)
  41. // - Incentivized ad rate limiting (see your app's Publisher
  42. // Settings dashboard)
  43. // - One of the mediated SDKs reported it had an ad to show
  44. // but did not display one when asked (a rare case)
  45. // - The SDK is waiting for a network request to return before an
  46. // ad can show
  47. }
  48. if (adState.Equals("available")) {
  49. // Sent when an ad has been loaded and is ready to be displayed,
  50. // either because we autofetched an ad or because you called
  51. // `Fetch`.
  52. }
  53. if (adState.Equals("fetch_failed")) {
  54. // Sent when an ad has failed to load.
  55. // This is sent with when we try to autofetch an ad and fail, and also
  56. // as a response to calls you make to `Fetch` that fail.
  57. // Some of the possible reasons for fetch failures:
  58. // - Incentivized ad rate limiting (see your app's Publisher
  59. // Settings dashboard)
  60. // - None of the available ad networks had any fill
  61. // - Network connectivity
  62. // - The given ad tag is disabled (see your app's Publisher
  63. // Settings dashboard)
  64. // - One or more of the segments the user falls into are
  65. // preventing an ad from being fetched (see your
  66. // Segmentation Settings dashboard)
  67. }
  68. if (adState.Equals("audio_starting")) {
  69. // The ad about to be shown will need audio.
  70. // Mute any background music.
  71. }
  72. if (adState.Equals("audio_finished")) {
  73. // The ad being shown no longer needs audio.
  74. // Any background music can be resumed.
  75. }
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement