Skip to content

Commit 69012be

Browse files
Invoke ad revenue callback on background thread (#140)
1 parent c3ec5c3 commit 69012be

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Runtime/Common/Events/Public/Interfaces/IAdRevenueListener.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ public interface IAdRevenueListener
1414
/// See <see href="https://docs.appodeal.com/unity/advanced/ad-revenue-callback"/> for more details.
1515
/// </summary>
1616
/// <param name="ad">contains info about the tracked impression.</param>
17+
/// <remarks>
18+
/// <para>
19+
/// On Android, this callback is invoked on a background thread to ensure ad revenue data
20+
/// is delivered immediately without loss, reducing discrepancies when forwarding to MMPs.
21+
/// </para>
22+
/// If you need to interact with Unity Engine APIs (e.g., UI updates), make sure to dispatch those calls to the main thread.
23+
/// See <see href="https://docs.appodeal.com/unity/advanced/main-thread-callbacks"/> for more details.
24+
/// </remarks>
1725
void OnAdRevenueReceived(AppodealAdRevenue ad);
1826
}
1927
}

Runtime/Common/Events/Public/Scripts/AppodealCallbacks.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ public static AdRevenue Instance
118118
/// </para>
119119
/// Arguments are of a type <see cref="AdRevenueEventArgs"/>.
120120
/// </summary>
121+
/// <remarks>
122+
/// <para>
123+
/// On Android, this event is raised on a background thread to ensure ad revenue data
124+
/// is delivered immediately without loss, reducing discrepancies when forwarding to MMPs.
125+
/// </para>
126+
/// If you need to interact with Unity Engine APIs (e.g., UI updates), make sure to dispatch those calls to the main thread.
127+
/// See <see href="https://docs.appodeal.com/unity/advanced/main-thread-callbacks"/> for more details.
128+
/// </remarks>
121129
public static event EventHandler<AdRevenueEventArgs> OnReceived;
122130

123131
private void InitializeCallbacks()

Runtime/Platforms/Android/Callbacks/AppodealAdRevenueCallback.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private void onAdRevenueReceive(AndroidJavaObject ad)
2525
{
2626
if (ad == null)
2727
{
28-
UnityMainThreadDispatcher.Post(_ => _listener?.OnAdRevenueReceived(null));
28+
_listener?.OnAdRevenueReceived(null);
2929
return;
3030
}
3131

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

44-
UnityMainThreadDispatcher.Post(_ => _listener?.OnAdRevenueReceived(adRevenue));
44+
_listener?.OnAdRevenueReceived(adRevenue);
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)