firebase / quickstart-unity

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

DynamicLinkReceived never fired on iOS #626

Closed gabetoth-dgh closed 3 years ago

gabetoth-dgh commented 4 years ago

Please fill in the following fields:

Unity editor version: 2018.4.16f1 Firebase Unity SDK version: 6.9.0, tried 6.13.0 too Firebase plugins in use (Auth, Database, etc.): auth, analytics, dynamic links, messaging, crashlytics Additional SDKs you are using (Facebook, AdMob, etc.): ironsource, tapjoy, appsflyer, helpshift Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac Platform you are targeting (iOS, Android, and/or desktop): iOS Scripting Runtime (Mono, and/or IL2CPP): IL2CPP

Please describe the issue here:

Links open or start application. Callback never gets called.

Please answer the following, if applicable:

Quickstart demo app works. Adding Firebase unitypackages and setting up the project was the same as in our app. We use custom domains.

repro rate: 100%

gabetoth-dgh commented 4 years ago

I've updated to 6.13.0 and it is still not working. Other firebase plugins work fine.

gabetoth-dgh commented 4 years ago

I've added a try catch block around it try { DynamicLinks.DynamicLinkReceived += OnDynamicLinkReceived; } catch (Exception ex) { Log.Error("[FirebaseHelper] {0}",ex.ToString()); }

and this is what came out: [FirebaseHelper] System.TypeInitializationException: The type initializer for 'Firebase.DynamicLinks.DynamicLinks' threw an exception. ---> Firebase.InitializationException: Crashlytics initialization failed with an unexpected error. ---> Firebase.InitializationException: Crashlytics initialization failed. Could not find Crashlytics initializer. at FirebaseHelper.<Start>b__14_0 (System.Threading.Tasks.Task'1[TResult] task) [0x00000] in <00000000000000000000000000000000>:0

chkuang-g commented 4 years ago

Hi @gabetoth-dgh The "Crashlytics Initialization failed" issue seems to be related to #623. This seems to happen when you install Firebase through Unity Package Manager. At the meantime, I would recommend you to use .unitypackage version to avoid the bug for now.

Regarding DynamicLinkReceived event never being fired, did you enable the Associated Domains capability in XCode project? https://firebase.google.com/docs/dynamic-links/ios/receive#open-dynamic-links-in-your-app

Also please try out our quickstart and follow the instruction. Let us know if you still have the issue.

Shawn

gabetoth-dgh commented 4 years ago

Hi, @chkuang-g,

Thanks for your reply. I've removed and imported the firebase packages that I need.

I had Associated domains set up correctly before.

DynamicLinkReceived now works.

chkuang-g commented 4 years ago

Oh interest. Do you mean that UPM version does NOT work even you had associated domain set up correctly?

In that case, this may be a bug. Please let us know.

Thank you!

gabetoth-dgh commented 4 years ago

@chkuang-g It's partly not working. If you have your domain set up and added the entries to associated domains then the dynamic links launch / open the app. The problem came afterwards.

Since that I have another issue. iOS: When the app is in background and I trigger a dynamic link, it brings the app to foreground and DynamicLinkReceived gets called. When the app is not running and you trigger a dynamic link, it starts up the app but DynamicLinkReceived never gets called. If you go back to the dynamic link, tap it again, the app comes to foreground and triggers DynamicLinkReceived two times. Android works as expected in any cases.

Please note that I am using version 6.6.0 again, because 6.13.0 and EDM breaks at so many points. I don't have access to any other sdk versions currently, I couldn't find them anywhere. I'm asking other coworkers maybe they have a more recent version other then 6.13.0.

ghus86 commented 4 years ago

@chkuang-g

I am also facing problem with dynamic links in recent iOS devices and recent versions of firebase

this is very strange for me it works in a iphone SE with iOS 11.3 or 11.4 but my clients repor problems with iphone 11 and X

instead of opening the app it goes for the preview page

if the user reboots the device it solves the issue when using firebase 6.2.2 but another app with the same base code using firebase 6.11 still goes to the preview page

hope this helps, it would be nice to have a fix for this there is a related issue in the ios channel https://github.com/firebase/firebase-ios-sdk/issues/4914#issuecomment-608519325

gabetoth-dgh commented 4 years ago

A minor update:

I got 6.12.0 .unitypackage files from a coworker, and that can be imported into any project without any hustle. Dynamic Links work, but still only if the app is in the background. If I start up the app with a Dynamic Link is not received from DynamicLinks.DynamicLinkReceived, it never gets called.

I was checking Device Console with the Console app and I found:

default 21:44:09.248306+0200    <my_app_name>   Enable module 'analytics' for 'Firebase.Analytics.FirebaseAnalytics, Firebase.Analytics'
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String)
Firebase.LogUtil:LogMessage(LogLevel, String)
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
default 21:44:09.248792+0200    <my_app_name>   Enable module 'auth' for 'Firebase.Auth.FirebaseAuth, Firebase.Auth'
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String)
Firebase.LogUtil:LogMessage(LogLevel, String)
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
default 21:44:09.252085+0200    <my_app_name>   Enable module 'dynamic_links' for 'Firebase.DynamicLinks.DynamicLinks, Firebase.DynamicLinks'
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String)
Firebase.LogUtil:LogMessage(LogLevel, String)
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
default 21:44:09.254115+0200    <my_app_name>   Enable module 'messaging' for 'Firebase.Messaging.FirebaseMessaging, Firebase.Messaging'
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String)
Firebase.LogUtil:LogMessage(LogLevel, String)
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()

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

default 21:44:09.275876+0200    <my_app_name>   DEBUG: Creating Firebase App __FIRAPP_DEFAULT for Firebase C++ 6.12.0
default 21:44:09.529624+0200    <my_app_name>   DEBUG: Added app name=__FIRAPP_DEFAULT: options, api_key=AIzaSyA7jhigdFQjq1E7NroLWG7WJlj_JLrCqYQ, app_id=1:853409910518:ios:16f835b536e20356, database_url=https://<my_app_name>.firebaseio.com, messaging_sender_id=853409910518, storage_bucket=<my_app_name>.appspot.com, project_id=<my_app_name> (0x4222c4f0)
default 21:44:09.535697+0200    <my_app_name>   Registering Crashlytics exception handlers
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String)
Firebase.LogUtil:LogMessage(LogLevel, String)
Firebase.Crashlytics.ExceptionHandler:Register()
Firebase.Crashlytics.PlatformAccessor:.cctor()
Firebase.Crashlytics.Crashlytics:Initialize()
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Firebase.FirebaseApp:InitializeCrashlyticsIfPresent()
Firebase.FirebaseApp:<CreateAndTrack>m__1()
System.Func`1:Invoke()
Firebase.Dispatcher:Run(Func`1)
Firebase.Platform.FirebaseHandler:RunOnMainThread(Func`1)
Firebase.FirebaseApp:CreateAndTrack(CreateDelegate, FirebaseApp)
Firebase.Fir<…>

default 21:44:10.191329+0200    <my_app_name>   6.17.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.
default 21:44:10.324784+0200    <my_app_name>   6.17.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
default 21:44:10.324831+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
default 21:44:10.324879+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS025026] Deferring to Firebase for event data collection
default 21:44:10.325135+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS025028] AdMob and Firebase are in use in this app, but are not linked. For analytics data consistency and integrity, it is highly recommended that you link your AdMob app to the corresponding Firebase app and re-download the GoogleServices-Info.plist file. See https://support.google.com/admob/answer/6383165 for more information.
default 21:44:10.325371+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60202000 started
default 21:44:10.325419+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
default 21:44:10.470824+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023000] Deep Link Web URL query is empty
default 21:44:10.777724+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
default 21:44:10.905271+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
default 21:44:11.257308+0200    <my_app_name>   [C9 Hostname#568c6ab1:443 tcp, url: https://firebasedynamiclinks-ipv6.googleapis.com/v1/installAttribution?key=AIzaSyA7jhigdFQjq1E7NroLWG7WJlj_JLrCqYQ, tls] start
default 21:44:11.259835+0200    <my_app_name>   [C10 Hostname#0ddb90f6:443 tcp, url: https://firebasedynamiclinks-ipv4.googleapis.com/v1/installAttribution?key=AIzaSyA7jhigdFQjq1E7NroLWG7WJlj_JLrCqYQ, tls] start
default 21:44:11.268363+0200    <my_app_name>   [C9 Hostname#568c6ab1:443 tcp, url: https://firebasedynamiclinks-ipv6.googleapis.com/v1/installAttribution?key=AIzaSyA7jhigdFQjq1E7NroLWG7WJlj_JLrCqYQ, tls] cancel
default 21:44:11.268413+0200    <my_app_name>   [C9 Hostname#568c6ab1:443 tcp, url: https://firebasedynamiclinks-ipv6.googleapis.com/v1/installAttribution?key=AIzaSyA7jhigdFQjq1E7NroLWG7WJlj_JLrCqYQ, tls] cancelled
default 21:44:11.590137+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
    dismiss = 1;
    "is_weak_match" = 1;
}
default 21:44:39.292370+0200    <my_app_name>   [C38 Hostname#82910d57:443 tcp, url: https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog, tls] start
default 21:44:40.503012+0200    <my_app_name>   FCM: Initialize Firebase Messaging
default 21:46:11.685023+0200    <my_app_name>   [C10 Hostname#0ddb90f6:443 tcp, url: https://firebasedynamiclinks-ipv4.googleapis.com/v1/installAttribution?key=AIzaSyA7jhigdFQjq1E7NroLWG7WJlj_JLrCqYQ, tls] cancel
default 21:46:11.685482+0200    <my_app_name>   [C10 Hostname#0ddb90f6:443 tcp, url: https://firebasedynamiclinks-ipv4.googleapis.com/v1/installAttribution?key=AIzaSyA7jhigdFQjq1E7NroLWG7WJlj_JLrCqYQ, tls] cancelled
    [C10.1 <private> 192.168.1.226:55544<->IPv4#72744a30:443]
    Connected Path: satisfied (Path is satisfied), interface: en0, ipv4, dns
    Duration: 120.489s, DNS @0.000s took 0.022s, TCP @0.027s took 0.008s, TLS took 0.299s
    bytes in/out: 3852/1226, packets in/out: 10/9, rtt: 0.006s, retransmitted packets: 0, out-of-order packets: 3
default 21:46:40.064440+0200    <my_app_name>   [C38 Hostname#82910d57:443 tcp, url: https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog, tls] cancel
default 21:46:40.066792+0200    <my_app_name>   [C38 Hostname#82910d57:443 tcp, url: https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog, tls] cancelled
    [C38.1 <private> 192.168.1.226:55578<->IPv4#5c64db34:443]
    Connected Path: satisfied (Path is satisfied), interface: en0, ipv4, dns
    Duration: 120.773s, DNS @0.000s took 0.004s, TCP @0.007s took 0.009s, TLS took 0.104s
    bytes in/out: 4058/1176, packets in/out: 9/9, rtt: 0.009s, retransmitted packets: 0, out-of-order packets: 0

but these bother me the most:

default 20:54:36.790595+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023000] Deep Link Web URL query is empty

default 20:54:37.490515+0200    <my_app_name>   6.17.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
    dismiss = 1;
    "is_weak_match" = 1;
}

The link is valid and working since it works the other way.

So, my current state:

chkuang-g commented 4 years ago

@ghus86 Thanks for providing the link.

Hi folk, just to clarify that you are experiencing issue with Dynamic Link on iOS no matter you installed Firebase through .unitypackage or UPM.

And @gabetoth-dgh, from your experience, Firebase 6.6.0 works but all 6.9.0, 6.12.0 and 6.13.0 failed.

This seems to be related to #519 and https://github.com/firebase/firebase-ios-sdk/issues/4914.

I did see internal bug filed for the iOS issue. Will let you know if there is any progress.

ghus86 commented 4 years ago

@chkuang-g I have tested only with unitypackges downloaded from firebase site

gabetoth-dgh commented 4 years ago

@chkuang-g My links open the app in every case, but they only work if the app is in background. If I start the app with dynamic links DynamicLinkReceived never gets fired. Sorry if I wasn't clear enough.

vzlomvl commented 4 years ago

My links open the app in every case, but they only work if the app is in background. If I start the app with dynamic links DynamicLinkReceived never gets fired. Sorry if I wasn't clear enough. Hello everyone. We have same issue. Unity editor version: 2018.4.20f1 Firebase Unity SDK version: 6.13.0 from .unitypackage Firebase plugins in use (Auth, Database, etc.): auth, analytics, dynamic links, messaging, crashlytics, realtime database Additional SDKs you are using (Facebook, AdMob, etc.): appsflyer, mix panel, one signal Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac Platform you are targeting (iOS, Android, and/or desktop): iOS Scripting Runtime (Mono, and/or IL2CPP): IL2CPP

Android works fine.

vzlomvl commented 4 years ago

The issue may be related to Appsflyer + Firebase. I tried uninstalling Appsflyer SDK, and after that Firebase Dynamic Links works correctly.

Hi @ghus86 Do you have Appsflyer SKD in the project too?

gabetoth-dgh commented 4 years ago

@vzlomvl We have appsflyer too. I can test it tomorrow.

ghus86 commented 4 years ago

@vzlomvl Thanks for the feedback but in my case I don't have Appsflyer SDK

vzlomvl commented 4 years ago

@chkuang-g Is Firebase using IMPL_APP_CONTROLLER_SUBCLASS to override UnityAppController? If so the issue is that other plugins are using this instruction too and one plugin can override another. I have tried to remove IMPL_APP_CONTROLLER_SUBCLASS from Appsflyer and after that Firebase Dinamic link work correctly. But Appsflyer can be broken after this.

vzlomvl commented 4 years ago

Finally I have localised issue. Looks like Firebase and Appsflyer are using application:continueUserActivity:restorationHandler and for some reason override each over.

Temporary workaround: I have added "[super application:application continueUserActivity:userActivity restorationHandler:restorationHandler];" to application:continueUserActivity:restorationHandler in AppsFlyerAppController and after that Firebase Dynamic Links work correctly.

image
ghus86 commented 4 years ago

@vzlomvl thanks for the sharing

@chkuang-g this doesnt fix my problem there is another issue about this dynamic link problem one interesting discovery is that it seems the problem is isolated in using dynamic links and safari https://github.com/firebase/firebase-ios-sdk/issues/5314

this is one of the strangest bugs I have found =/

gabetoth-dgh commented 4 years ago

@vzlomvl It worked! Adding [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; passed down the url.

MartinGonzalez commented 4 years ago

Is it possible that the apple-site-app-association has a new format for iOS 13? Its driving me crazy this issue, I cannot open my app with a dynamic link having it installed. Some say that is an iOS issue, others say that restarting the device works :/

https://developer.apple.com/documentation/safariservices/supporting_associated_domains_in_your_app?language=objc

carlplaylab commented 4 years ago

@vzlomvl It worked! Adding [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; passed down the url.

I am working on a Unity-IOS project and have both AppsFlyer and Firebase dynamic links. My firebase DynamicLinks.DynamicLinkReceived is also never triggered, but my Firebase dynamic links open my app just fine. I just have no way of getting the link without "DynamicLinkReceived". Note: The dynamic links work perfectly on Android and listeners for DynamicLinkReceived receives the url just fine.

Edit: Adding [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; worked. Also enabled keychain sharing thru my entitlements file.

gromilQaaaa commented 4 years ago

Looks like I have the same problem. I recieve no link variables //google/link/?dismiss=1&is_weak_match=1

I've updated Appsflyer to v5 latest, and Use UPM Firebase 6.14

My Android app is also broken and doesn't recieve variables

vzlomvl commented 4 years ago

Hi @gromilQaaaa v5 of Appsflyer have option to swizzling application methods which can fix conflict with Firebase on iOS. https://github.com/AppsFlyerSDK/appsflyer-unity-plugin/issues/12#issuecomment-624502632

vzlomvl commented 4 years ago

@gromilQaaaa JFYI: Looks like Appsflyer + Firebase conflict was fixed in v5.3.1 version of the Appsflyer.

chkuang-g commented 3 years ago

Hey folks,

Sorry for the wait. Just an update: I filed an internal ticket b/171437333 for this issue.

Just to confirm, do you guys still see this issue and require workaround mentioned in https://github.com/firebase/quickstart-unity/issues/626#issuecomment-612060018 with the latest Unity SDK 6.16.1?

Please let us know. Shawn

vzlomvl commented 3 years ago

Hi @chkuang-g. No, after updating to version 5.3.1 Appsflyer we no longer have this issue in our project. Thanks.

chkuang-g commented 3 years ago

Thanks for the confirmation, @vzlomvl !

I also hear back from iOS team and this should be fix in 4.1.0 https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseDynamicLinks/CHANGELOG.md#v410

Unity SDK 6.15.2 is using Dynamic Links 4.0.8 Unist SDK 6.16.0 is using Dynamic Links 4.3.0

@gabetoth-dgh Please let us know if the latest Unity SDK resolve your issue.

google-oss-bot commented 3 years ago

Hey @gabetoth-dgh. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 3 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@gabetoth-dgh if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.