Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Runtime/Common/Events/Public/Interfaces/IAdRevenueListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public interface IAdRevenueListener
/// See <see href="https://docs.appodeal.com/unity/advanced/ad-revenue-callback"/> for more details.
/// </summary>
/// <param name="ad">contains info about the tracked impression.</param>
/// <remarks>
/// <para>
/// On Android, this callback is invoked on a background thread to ensure ad revenue data
/// is delivered immediately without loss, reducing discrepancies when forwarding to MMPs.
/// </para>
/// If you need to interact with Unity Engine APIs (e.g., UI updates), make sure to dispatch those calls to the main thread.
/// See <see href="https://docs.appodeal.com/unity/advanced/main-thread-callbacks"/> for more details.
/// </remarks>
void OnAdRevenueReceived(AppodealAdRevenue ad);
}
}
8 changes: 8 additions & 0 deletions Runtime/Common/Events/Public/Scripts/AppodealCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ public static AdRevenue Instance
/// </para>
/// Arguments are of a type <see cref="AdRevenueEventArgs"/>.
/// </summary>
/// <remarks>
/// <para>
/// On Android, this event is raised on a background thread to ensure ad revenue data
/// is delivered immediately without loss, reducing discrepancies when forwarding to MMPs.
/// </para>
/// If you need to interact with Unity Engine APIs (e.g., UI updates), make sure to dispatch those calls to the main thread.
/// See <see href="https://docs.appodeal.com/unity/advanced/main-thread-callbacks"/> for more details.
/// </remarks>
public static event EventHandler<AdRevenueEventArgs> OnReceived;

private void InitializeCallbacks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private void onAdRevenueReceive(AndroidJavaObject ad)
{
if (ad == null)
{
UnityMainThreadDispatcher.Post(_ => _listener?.OnAdRevenueReceived(null));
_listener?.OnAdRevenueReceived(null);
return;
}

Expand All @@ -41,7 +41,7 @@ private void onAdRevenueReceive(AndroidJavaObject ad)
RevenuePrecision = ad.Call<string>(AndroidConstants.JavaMethodName.AdRevenue.GetRevenuePrecision)
};

UnityMainThreadDispatcher.Post(_ => _listener?.OnAdRevenueReceived(adRevenue));
_listener?.OnAdRevenueReceived(adRevenue);
}
}
}