Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question FirebaseMessaging.GetTokenAsync() crashing on iOS

Discussion in 'iOS and tvOS' started by man-teiv, Apr 15, 2021.

  1. man-teiv

    man-teiv

    Joined:
    Mar 28, 2020
    Posts:
    6
    I'm using Unity 2019.4.23f1 on Windows 10 and I have the following lines I want to execute on an iOS build of my app:
    Code (CSharp):
    1.  
    2. public async Task<string> TokenFCM()
    3. {   // Return FCM token if on mobile, otherwise ""
    4. #if UNITY_ANDOID || UNITY_IOS
    5.     Debug.Log("Get token");
    6.     return await Firebase.Messaging.FirebaseMessaging.GetTokenAsync();
    7.     Debug.Log("End get token");
    8. #else
    9.     return "";
    10. #endif
    11. }
    I'm using iOS project builder to compile it.
    Whenever I'm trying to run that line, the app crashes instantly. Using the debug console from iOS project builder, I'm able to catch the following lines before it crashes:
    It almost looks like it's calling the same commands cyclically until it crashes.
    Is it possible to avoid it crashing? Is there something I can add to the code or to my unity settings?
    Thanks!