App crash after registerForPushNotifications on iOS - FIRInstanceID setAPNSToken:type:

Hello,

I continued my tests and I arrived at this observation:

By cleaning any call to Firebase Analytics in my .lua files but leaving only the call to the plugin in the build.settings we have the crash.

plugins =     {                  ["plugin.firebaseAnalytics"] = {           publisherId = "tech.scotth",         },         ["plugin.notifications.v2"] =         {             publisherId = "com.coronalabs",         },     },

 

Apparently, The problem does not come from our code but an incompatibility between the two plugins during compilation.

@Scott Harrison please help!

@troylyndon, @GBF Comm,

I’m kind of confused now. Troy you say removing the Analytics plugin causes the app to still crash. @GBF you say removing the Analytics plugin solves the problem. 

@troylyndon do you have a sample app that demos this crash? (stripped down app). If you do, it might be worth the two of you sharing each other’s test case and get independent verification. Maybe it will help narrow down what the difference is between your two experiences.

The only one who can address problems with Scott’s plugins is Scott. I can’t speak to how much he monitors the forums, but the marketplace should have contact information for him as well as his support channels. It’s best you reach out directly to him. 

Rob

@Rob Miracle.

Yes, totally removing the Analytics plugin solves the problem. As i said before in my previous post, juste leaving the declaration in Build.settings cause the crash. Perhaps troylyndon doesn’t remove the plugin decalaration in the build.settings? Do you troylyndon?

I sent to scott harrison a mail with sample files to reproduce the problem. It only remains for me to wait for his answer. I will keep you informed on this topic of the continuation and, I hope, of the resolution of the problem.

Thanks
GBF Comm

@Rob, @GBF Comm,
Yes, there is no doubt there is a PLUGIN CONFLICT between Firebase and Notifications. With that said, let me explain what I have working and what I’m waiting on Scott and Rob to fix.

PRIORITIES
For iOS, I’ve decided it’s more important for me to run Firebase (and track device app launching) than to have notification. So, on iOS, I use the Firebase.analytics plugin without notifications. Hopefully, Rob will find out the problem and fix notifications soon. As for ANDROID, both notifications and firebase work perfectly for Android versions <8, but Firebase.analytics does NOT work on Android versions 8+.

The first key to having this work in certain cases was NOT to include the require(“plugin.notifications.v2”) definition in the code unless the platform is Android - iOS platform never includes the require.

The second key to having these plugins play nice, some of the time at least, is to make sure not to include the require(“plugin.firebaseAnalytics”) definition or run the firebase init code until at least 5 seconds after the notifications initialization occurs.

So, although it is odd to have such checks and dependencies between plugins, it’s the only thing I could do without waiting any longer - I just released my new game app today:  http://onelink.to/wpt53m and this game incorporates these odd dependencies properly.

So Rob, I’m still working with Scott (when he has time) to resolve the Firebase.analytics failure on Android v8+ - we sent him the cash to purchase an Android 8 phone, so that should be coming. The question is, what about the notifications crash? In view of Firebase’s here-to-stay liklihood, can CoronaLabs acquire Scott’s plugin and help him to fix the Android 8+ problem, too? It has already been a couple of weeks and he needs help IMHO.

btw, @GBFComm, keeping or removing the definition in my build.settings for iOS or Android makes no difference. The key is not to include the REQUIRE outside of a code routine. For example, function init_notifs() should have the require( definition of either plugin within the subroutine, so that Lua never attempts to init the plugin unless the code needing it asks for it. I hope this makes sense.

@Rob, it’s also important to understand that Google Ads and Google Play can incorporate data from Firebase, and for this reason, I’m arguing and begging CoronaLabs to see the importance of implementing GCM, which is also a free service like OneSignal, but will not likely ever have the same support issues I’ve faced with my app that has been crashing for several months on Android v8+ devices. Even with a Firebase update, since Scott’s code still doesn’t work on Android 8+, at least it is working for <8 for now. The point is, I’m asking for Corona to seriously look at the notifications solution that uses GCM and recognize the importance of either taking over Scott’s plugin (for some benefit) or creating a basic Firebase plugin that will at least report data to Firebase, even if it doesn’t retrieve data from it. I’m not sure that last sentence was completly accurate, as I don’t understand how to communicate with Firebase directly, yet.

Troy, GCM to me means Google Cloud Messaging. This is Google’s old push notification system. Google has deprecated GCM and is only supposed to be allowing Firebase Cloud Messaging (FCM) push notifications now. However I believe, due to the volume of GCM apps in the store, Google is having a hard time shutting that service down.

The original notifications plugin (v1) uses GCM. If you want to skip using FCM, you could try to drop back to the V1 of the notification plugin. It should be code compatible.

Now what I can’t say is if we have updated the notifications v1 plugin because we are under the assumption it’s been deprecated by Google. You could run into ANR and Crash problems in particular on Android 8 devices.

I can speak with Engineering about rebuilding the v1 plugin, but given that Google is discouraging people from using GCM, I’m not sure how much traction I can get.  We can’t just take Scott’s plugin from him. If he wants us to help, he can approach us about it and then we can look at options then.

We have multiple other analytics offerings that can track installs and app launching. What benefits does Firebase Analytics provide that our Google Analytics or GameAnalytics or any of our other options?

Rob

@Rob, thank you for your thoughtful reply, as always.

I was incorrect in my reference of GCM - I meant FCM, so my mistake.

I believe you are right about v1 of the notifications plugin, as it likely will crash just as oneSignal does.

So, is it safe to say that if I don’t include firebase.analytics within my app, the Firebase stream will still recognize each device because of the new v2 notifications plugin, and therefore, firebase.analytics is unnecssary in reporting data to Firebase? In other words, was I wrong to assume the firebase.analytics plugin was necessary to report the install and app startups?

The notification plugin’s job is to register the device with FCM. I’m not sure what you mean by the “Firebase stream”. What data are you reporting to firebase? 

If you want to track app installs and app startups, you probably need some form of analytics. The question is why do you feel Firebase needs to know this information.

Rob

Hy,

I have been facing the same problem, I have updated firebase to the latest version, but noticed that firebase Analytics was missing, I downgraded the firebase version and got Installing FirebaseAnalytics (5.2.0)

but when I run the app it crashes on 

[[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRMessagingAPNSTokenTypeSandbox];

I get the following error:

[FIRInstanceID setAPNSToken:type:]: unrecognized selector sent to instance 0x1c40bb960

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: '-[FIRInstanceID setAPNSToken:type:]: unrecognized selector sent to instance 0x1c40bb960’

 

Knowing that this method is related to FirebaseAnalytics 

 

Any idea how I can make it work? I am using firebase to enable push notifications.

 

Thank you for your help.