firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
825 stars 428 forks source link

iOS Firebase 6.10 version TokenReceived is never called #705

Closed sampsao closed 4 years ago

sampsao commented 4 years ago

Please fill in the following fields:

Unity editor version: 2018.3.14f1 Firebase Unity SDK version: 6.10 Source you installed the SDK (.unitypackage or Unity Package Manager): .unitypackage Firebase plugins in use (Auth, Database, etc.): Messaging, Crashlytics, DynamicLinks, Analytics Additional SDKs you are using (Facebook, AdMob, etc.): Google Play, Facebook, Apple Sign in, Appsflyer, Ironsource ad mediation( mediation networks Ironsource, UnityAds, Admob) Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac 10.14.6 Platform you are targeting (iOS, Android, and/or desktop): iOS, Android Scripting Runtime (Mono, and/or IL2CPP): IL2CPP

Please describe the issue here:

We updated all of our plugins back in February(when 6.10 was the latest version). We have recently added Ironsource mediation in to our project. We just noticed that we are not receiving any push notifications on iOS anymore. Android is working correctly. We have followed the setup guides again but it is still not working. From the logs it looks like registering for the push tokens is working fine, but we never receive any callback to the TokenReceived callback events. This is how we initialize Firebase:

public static void Initialize()
        {
            Debug.Log("INITIALIZE FCM");
            Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
                var dependencyStatus = task.Result;
                if (dependencyStatus == Firebase.DependencyStatus.Available)
                {
                    var app = Firebase.FirebaseApp.DefaultInstance;
                    Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
                    Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
                    Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
                }
                else
                {
                    UnityEngine.Debug.LogError(System.String.Format(
                    "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                    // Firebase Unity SDK is not safe to use here.
                }
            });
        }

And here is what we see in the logs:

2020-06-10 13:42:07.417830-0400 com.company.projectname[775:347340] FCM: Initialize Firebase Messaging
FCM: Initialize Firebase Messaging

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2020-06-10 13:42:07.418475-0400 com.company.projectname[775:347340] FCM: Using FCM senderID 205293207962
FCM: Using FCM senderID 205293207962

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2020-06-10 13:42:07.419753-0400 com.company.projectname[775:347340] FCM: Retrieve registration token
FCM: Retrieve registration token

After those calls we the application shows the native popup asking for permission for push notifications. After they are allowed, no callbacks are received. Do you have any idea what could be causing this? We have checked all the service info files and everything and they should be working properly as we do get analytic events to the dashboard. We're suspecting it could be because of another plugin, but as the problem has persisted unnoticed for a while, it's hard for us to be certain about it.

Please answer the following, if applicable:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? No, haven't even tried as they have worked before and I think this is related to the complexity of our project (all the other SDKs). As we have many SDKs in the project, it's not very easy to update just the Firebase plugin to see if it would fix this. Any help is appreciated.

What's the issue repro rate? (eg 100%, 1/5 etc) 100%

DellaBitta commented 4 years ago

Hi @sampsao,

There aren't any known issues for Messaging in 6.10. We do use swizzling for messaging on iOS so my guess is that there could be another plugin that's causing some sort of interferenece. Unfortunately I'm not sure of a good way to debug this other than starting with the messaging test app to first test a successful path and introduce each library one at a time to see which one causes a problem, or to pair down your own app to see if you can get it to work with only Firebase messaging and then add each library one at a time there.

Keep us posted!

sampsao commented 4 years ago

Hi @DellaBitta

This is pretty much what I thought. I think the only solution is to take everything off and start implementing them back one by one, starting from Firebase. I will update info here if I encounter anything odd or worth mentioning, but as there seems to be no quick fix or workaround I'm going to close this issue.