Quickstart-unity: Firebase Messaging. iOS crash. When try to use FirebaseMessaging class.

Created on 5 Jun 2017  Â·  34Comments  Â·  Source: firebase/quickstart-unity

When I run the project the first time, Xcode gives the following error. Found that the error crashes after the call to FirebaseMessaging class. I think on initialization of FirebaseMessaging class.

screen shot 2017-06-05 at 16 06 14

bug

Most helpful comment

We pushed a 4.0.1 bug fix release that should resolve this issue.
https://firebase.google.com/support/release-notes/unity#4.0.1

Cheers,
Stewart

All 34 comments

Hi, we had a regression in the 3.0.3 release (caused by the
play-services-resolver) which broke pinning to a specific release of iOS
Cocaopods. The error you're reporting is caused by using the 3.0.3 Unity
release with the 4.x Firebase iOS SDK. The 4.x Firebase iOS SDK introduced
some breaking API changes, one of which you've found here.

If you import the latest Play Services Resolver
https://github.com/googlesamples/unity-jar-resolver/blob/master/play-services-resolver-1.2.23.0.unitypackage
into your project and rebuild for iOS the issue should go away as the build
will pull the correct iOS SDK to build against.

Cheers,
Stewart

On Mon, Jun 5, 2017 at 5:08 AM, rumsterrt notifications@github.com wrote:

When I run the project the first time, Xcode gives the following error.
Found that the error crashes after the call to FirebaseMessaging class. I
think on initialization of FirebaseMessaging class.

[image: screen shot 2017-06-05 at 16 06 14]
https://cloud.githubusercontent.com/assets/15135298/26783370/005c5d3c-4a22-11e7-82d0-41f53031639f.png

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/firebase/quickstart-unity/issues/87, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AFw1RGenp2kWu0nk-PXz_lcaD_w5GoXHks5sA-_BgaJpZM4Nv9Xe
.

It's work!) Thank you

I'm still seeing this exact same crash after importing the updated Play Services Resolver. Any ideas?

I'm having to disable Cocoapods in order to use Unity Cloud Build so am adding the frameworks through a post process build attribute if that makes any difference.

Any help would be much appreciated!

If you're having issues with Unity Cloud Build & Cocoapods that's pretty surprising as we added support a couple of months ago. Essentially, if Cocoapods (the tool) isn't present, we download Cocoapods and install it on the UCB host machine then run "pod repo update" and "pod install" in the same way as a normal build. It would be great if you could share build logs, if you can't post publicly you can email our support channel (https://firebase.google.com/support/contact/troubleshooting/), mention me (smiles@) and they'll make their way to our team.

If you really want to disable the Cocoapod installation you'll need to use the frameworks from 3.17.0 Firebase iOS SDK (https://dl.google.com/firebase/sdk/ios/3_17_0/Firebase-3.17.0.zip).

Cheers,
Stewart

I had to disable cocoa pods and manually add the frameworks as well as making other post build processes (as other people have found here https://github.com/googleads/googleads-mobile-unity/issues/333) in order to get past the following errors in UCB logs...

12822: [xcode] ld: warning: directory not found for option '-L/BUILD_PATH/Library/.../Release-iphoneos/GoogleToolboxForMac'
12823: [xcode] ld: warning: directory not found for option '-L/BUILD_PATH/Library/.../Release-iphoneos/Protobuf'
12824: [xcode] ld: library not found for -lGoogleToolboxForMac
12825: [xcode] clang: error: linker command failed with exit code 1 (use -v to see invocation)

My builds work fine for Android so appeared to be a pods issue. Adding frameworks manually has solved the above but I am getting the initial crash on didRefreshRegistrationToken. I'll try 3.17.0.

Thanks

UPDATE:- updating to 3.17.0 does appear to have fixed the didRefreshRegistrationToken crash but if there is any advice on the pods issue that'd be great

We just published a fix for this https://firebase.google.com/support/release-notes/unity#4.0.0 .

Please reopen if you continue to have issues.

Cheers,
Stewart

Hi Stewart

I've updated to the 4.0.0 plugin and trying to run with pods but am still getting the following uncaught exception...

Jun 13 10:13:08 Gs albert[1725] <Notice>: Uncaught exception: NSInvalidArgumentException: -[UIApplication messaging:didRefreshRegistrationToken:]: unrecognized selector sent to instance 0x10540a960
(
    0   CoreFoundation                      0x00000001830f6ff8 <redacted> + 148
    1   libobjc.A.dylib                     0x0000000181b58538 objc_exception_throw + 56
    2   CoreFoundation                      0x00000001830fdef4 <redacted> + 0
    3   CoreFoundation                      0x00000001830faf54 <redacted> + 916
    4   CoreFoundation                      0x0000000182ff6d4c _CF_forwarding_prep_0 + 92
    5   albert                              0x0000000101376408 -[FIRMessaging defaultInstanceIDTokenWasRefreshed:] + 176
    6   CoreFoundation                      0x00000001830915f4 <redacted> + 20
    7   CoreFoundation                      0x0000000183090d08 <redacted> + 400
    8   CoreFoundation                      0x0000000183090a84 <redacted> + 60
    9   CoreFoundation                      0x00000001830ff7a8 <redacted> + 1412
    10  CoreFoundation                      0x0000000182fd495c _CFXNotificationPost + 376
    11  Foundation                          0x0000000183b3f3f0 <redacted> + 676
    12  CoreFoundation                      0x00000001830a49a8 <redacted> + 32
    13  CoreFoundation                      0x00000001830a2630 <redacted> + 372
    14  CoreFoundation                      0x00000001830a2974 <redacted> + 692
    15  CoreFoundation                      0x0000000182fd2da4 CFRunLoopRunSpecific + 424
    16  GraphicsServices                    0x0000000184a3c074 GSEventRunModal + 100
    17  UIKit                               0x000000018928d058 UIApplicationMain + 208
    18  albert                              0x0000000100100484 main + 228
    19  libdyld.dylib                       0x0000000181fe159c <redacted> + 4
)

I need to update to the 4.0.0 plugin as its fixes an issue with some Android devices but I now don't seem to be able to disable Cocoapods and use the old 3.17.0 libraries for iOS as a workaround to this issue.

Any help would be great. Thanks

Hi

I'm also seeing this in 4.0.0: Uncaught exception: NSInvalidArgumentException: -[UIApplication messaging:didRefreshRegistrationToken:]: unrecognized selector sent to instance..

If you're manually adding frameworks to your project you'll need to upgrade
to the 4.0.2 iOS SDK.

https://firebase.google.com/docs/ios/setup#frameworks

Cheers,
Stewart

On Tue, Jun 13, 2017 at 7:18 AM, LoveLindberg notifications@github.com
wrote:

Hi

I'm also seeing this in 4.0.0: Uncaught exception:
NSInvalidArgumentException: -[UIApplication messaging:didRefreshRegistrationToken:]:
unrecognized selector sent to instance..

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/firebase/quickstart-unity/issues/87#issuecomment-308131274,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFw1RB9MXt-4GSlEkP590bMIcAAuiH6fks5sDppDgaJpZM4Nv9Xe
.

Hi Stewart

I've gone back to manually adding the frameworks (4.0.2) and still getting the same uncaught exception. Any ideas?

Thanks

I upgraded to 4.0.2 yesterday from 3.0.3 and now i am getting crash when application is installed for the first time with unity. It doesn't come in subsequent launches. So every user is experiencing a crash when app in installed and opened for the first time.

Crash Details:
2017-06-14 15:39:05.469816+0530 myapp[7711:2604986] Uncaught exception: NSInvalidArgumentException: -[UIApplication messaging:didRefreshRegistrationToken:]: unrecognized selector sent to instance 0x105506030
(
0 CoreFoundation 0x0000000187736ff8 + 148
1 libobjc.A.dylib 0x0000000186198538 objc_exception_throw + 56
2 CoreFoundation 0x000000018773def4 + 0
3 CoreFoundation 0x000000018773af54 + 916
4 CoreFoundation 0x0000000187636d4c _CF_forwarding_prep_0 + 92
5 myapp 0x0000000100b186fc -[FIRMessaging defaultInstanceIDTokenWasRefreshed:] + 176
6 CoreFoundation 0x00000001876d15f4 + 20
7 CoreFoundation 0x00000001876d0d08 + 400
8 CoreFoundation 0x00000001876d0a84 + 60
9 CoreFoundation 0x000000018773f7a8 + 1412
10 CoreFoundation 0x000000018761495c _CFXNotificationPost + 376
11 Foundation 0x000000018817f3f0 + 676
12 CoreFoundation 0x00000001876e49a8 + 32
13 CoreFoundation 0x00000001876e2630 + 372
14 CoreFoundation 0x00000001876e2974 + 692
15 CoreFoundation 0x0000000187612da4 CFRunLoopRunSpecific + 424
16 GraphicsServices 0x000000018907c074 GSEventRunModal + 100
17 UIKit 0x000000018d8cd058 UIApplicationMain + 208
18 myapp 0x00000001000174ac main + 172
19 libdyld.dylib 0x000000018662159c + 4
)
2017-06-14 15:39:05.473693+0530 myapp[7711:2604986] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIApplication messaging:didRefreshRegistrationToken:]: unrecognized selector sent to instance 0x105506030'
*
First throw call stack:
(0x187736fe0 0x186198538 0x18773def4 0x18773af54 0x187636d4c 0x100b186fc 0x1876d15f4 0x1876d0d08 0x1876d0a84 0x18773f7a8 0x18761495c 0x18817f3f0 0x1876e49a8 0x1876e2630 0x1876e2974 0x187612da4 0x18907c074 0x18d8cd058 0x1000174ac 0x18662159c)
libc++abi.dylib: terminating with uncaught exception of type NSException

Any update on this issue? (I can't reopen it)

@stewartmiles : Can u reopen this issue.

We have a fix going through our release process right now. It's going to take a few hours for us to QA as well, we're hoping to have something ready tonight (PST).

We pushed a 4.0.1 bug fix release that should resolve this issue.
https://firebase.google.com/support/release-notes/unity#4.0.1

Cheers,
Stewart

We updated to the posted 4.0.1 Unity release and still get this crash. Can you please reopen this issue and possibly provide a manual work-around?

Hi @jasonmarziani,

We're having trouble reproducing the bug. I definitely see the crash on 4.0.0, but 4.0.1 seems to work for me. Can you verify that you've updated the unity package? And if you're still seeing the error can you give me more details? Is this the exact same crash as the 4.0.0?

@alexames I figured out our use case and why we were still getting this crash. We delay prompting players to accept notifications until the player has opened the game 3 times. If we call FirebaseApp.CheckDependencies() without adding

Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;

we get the crash.

I made an empty project to demonstrate what we are doing. We call this from our AppController's Awake method:

_firebaseManager = new FirebaseManager();
 _firebaseManager.Init(() => {});

And here is how we init Firebase.

using UnityEngine;
using Firebase;
using System;

public class FirebaseManager 
{

    private DependencyStatus dependencyStatus = DependencyStatus.UnavailableOther;

    private const string NumberOpensKey = "FirebaseManager.NumberOpensKey";

    private int NumberOpens
    {
        get { return PlayerPrefs.GetInt(NumberOpensKey, 0); }
        set { PlayerPrefs.SetInt(NumberOpensKey, value); }
    }

    public void Init(Action completion) 
    {
        dependencyStatus = FirebaseApp.CheckDependencies();
        if (dependencyStatus != DependencyStatus.Available) 
        {
            FirebaseApp.FixDependenciesAsync().ContinueWith(task => 
            {
                dependencyStatus = FirebaseApp.CheckDependencies();
                if (dependencyStatus == DependencyStatus.Available) 
                {
                    if (completion != null) completion.Invoke();
                } 
                else 
                {
                    Debug.LogError("Could not resolve all Firebase dependencies: " + dependencyStatus);
                }
            });
        } else {
            if (completion != null) completion.Invoke();
        }

    if(NumberOpens > 2){
        Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
        Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
    }
        NumberOpens++;
    }

    public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token) 
    {
        UnityEngine.Debug.Log("*** Received Registration Token: " + token.Token);
    }

    public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) 
    {
        UnityEngine.Debug.Log("*** Received a new message from: " + e.Message.From);
        UnityEngine.Debug.Log("*** message data: " + e.Message.Data);
        UnityEngine.Debug.Log("*** message raw: " + e.Message.RawData);
    }

}

Thanks for the additional information, we're looking into it. I'll let you know what we find.

So I've looked at this on iOS (and on Android for good measure) and I can't recreate the crash. Can you give me more information about what platform you're on, and which versions of Unity and Firebase
fuore using?

Just to update from my side. Its working for us in iOS without any issues with updated sdk.

I just checked my test project and I still get the crash from a fresh app open on iOS using FirebaseMessaging 4.0.1. May I push my test scene to a public repo and include the installed Firebase files?

I'm using OSX Sierra, Unity 5.6.1f1, and XCode 8.3.2 for the build, iPhone 6 running iOS 10.3.1 for the device.

Yeah, go ahead and put up a test scene and we'll try running that on our end and see what happens.

Thanks, we've been able to reproduce the crash with your example. I'll let you know when we have a fix or workaround for you.

We're trying to get a release out asap that includes a fix for this. We'll update this bug when the release is posted.

Firebase Unity SDK version 4.0.2 has been released, which should resolve this issue: https://firebase.google.com/support/release-notes/unity#4.0.2

Jon

@jonsimantov The issue still seems to continue _only on_ ios 9.3.2 with Firebase 4.0.2 update. Higher ios versions are able to include the library on runtime without a problem.

Has this been fixed on ios 9 with Firebase 4.0.3?

I think this needs to be reopened or made into a different ticket.
The app still crashes on startup for ios 9 devices still exist on 4.0.3.

This is the error that comes up:
dyld: Library not loaded: /System/Library/Frameworks/UserNotifications.framework/UserNotifications
  Referenced from: /var/containers/Bundle/Application/"application path"
  Reason: image not found

The UserNotifications.framework is added, but the real issue is that the UserNotifications.framework works from ios 10 and up. It won't work for anything lower than 10, so there needs to be checks and a different way needs to be implemented for lower ios versions.

Here is something I found with a quick google search: https://stackoverflow.com/questions/42688760/local-and-push-notifications-in-ios-9-and-10-using-swift3

@josh-flyclops are you weak linking the UserNotifications framework? If not you'll see an "image not found" error when running on iOS 9.

Yeah, I realized that was the issue after I posted. I didn't catch it right away because I put frameworks on my own and it must have slipped through the cracks.

Can the docs be updated to specify that the UserNotifications.framework should be set to Optional instead of Required?
https://firebase.google.com/docs/cloud-messaging/unity/client

@josh-flyclops will do

awesome, thanks!

Was this page helpful?
0 / 5 - 0 ratings