Firebase Google Analytics Issue

Bhuwan 616 Reputation points
2022-10-02T04:18:32.94+00:00

Hi

i am getting below issue when logging firebase google analytics.

246716-image.png

246722-image.png

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
0 comments No comments
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,221 Reputation points Microsoft Vendor
    2022-10-04T02:42:09.973+00:00

    Hello @Bhuwan ,

    The error means that the method cannot be called in Main/UI thread, you could try to run the code on another thread by Task.Run Method :

    Task.Run( () => {  
    ...  
    }  
    

    In addition, you could try to use Xamarin.Essentials and determine if code is running on the Main Thread:

    if (MainThread.IsMainThread)  
    {  
        // Code to run if this is the main thread  
    }  
    else  
    {  
        // Code to run if this is a secondary thread  
    }  
    

    Best Regards,
    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful