firebase / quickstart-unity

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

Dynamic Links DynamicLinkReceived not called on app start on iOS #436

Closed novavision closed 5 years ago

novavision commented 5 years ago

Unity editor version: 2019.1.8f1 Firebase Unity SDK version: 6.2.0, 6.2.2 Firebase plugins in use: Dynamic Links Additional SDKs you are using: multiple, but issue occurs with single Firebase SDK in a project Platform you are using the Unity editor on: Mac Platform you are targeting: iOS

Setting up Dynamic Links for iOS and using a link to open the app to pass the parameters DynamicLinks.DynamicLinkReceived callback not called while on Android everything is fine. Debugging Firebase (setting log level to "Info") I see that actually link been passed to sdk, but no action triggered. You can check the log XCode entries here.

This issue is reproducible on the empty project just installing the Dynamic Links package.

Not sure, can it be related or not, but my Pod file entry is:

target 'Unity-iPhone' do pod 'Firebase/Core', '6.3.0' pod 'Firebase/DynamicLinks', '6.3.0'

but I am using 6.2.2 SDK

novavision commented 5 years ago

It would be great to get any response. This is a showstopper and we can't publish our updated app. Otherwise will need to migrate to another deeplink sdk

cynthiajoan commented 5 years ago

Hi @novavision , sorry for the inconvenience you are running into. I'm trying to reproduce the issue, and would like to understand the problem better.

I saw this line exist in the log: "2019-08-01 19:01:38.970466+0300 app[8432:7794765] DEBUG: Received link: invite_id= url= match_strength=0 result=0 error= Received link: invite_id= url= match_strength=0 result=0 error=", seems like the callback is triggered, however parameters are empty. So I'd like to ask two things to help me dig deeper:

1) Could you post the code that you are testing in your empty project, so I have a better understanding of the use case. 2) You mentioned it works on Android, can you post the log from Android as well for comparison?

Thanks!

novavision commented 5 years ago

I have already spent too much time on Firebase integration and finding your bugs. Yesterday I have realized that short links are not parsed in Unity SDK, what means I can't get custom params from the deeplink. So ****ing useless. Migrated to Branch.io and never will use Firebase products anymore - that's the worst experience I ever had for 7 years of development.

cynthiajoan commented 5 years ago

Hi @novavision, really sorry that you had a bad experience, and we would like to fix that.

I will keep debugging on the problem and post update here. In the mean time, any more information (log / code snippet / use case) will be appreciated.

cynthiajoan commented 5 years ago

Update: I use the sample app, tested with two scenario: 1) Generate short link from the app, and use that link, which opens the app, received the url and printed out. 2) Generate short link from firebase console, use that link, which also opens the app, received the url and printed out.

During my test, I noticed the following steps might easily get missed for iOS setup (instruction here), which is critical to receive DynamicLinks on iOS. 1) Make sure the bundle id in Unity project is same with the package name in firebase console 2) Copy the dynamic links domain for your project under the Dynamic Links tab of the Firebase console e.g xyz.app.goo.gl and assign it to the string DynamicLinksDomain on the UIHandler object in the MainScene. 3) Configure the iOS project Capabilities in xcode, to send invites and receive links. (last section in instruction page, iOS build).

DooblyNoobly commented 5 years ago

Hi @cynthiajoan I'm having the same problem. Here is my code for receiving the links:

using System;
using UnityEngine.UI;
using Firebase.DynamicLinks;
using UnityEngine;

public class DeepLinkingManager : MonoBehaviour
{
    public Text debugText;

    void Start()
    {
        DynamicLinks.DynamicLinkReceived += OnDynamicLink;
    }

    // Display the dynamic link received by the application.
    void OnDynamicLink(object sender, EventArgs args)
    {
        var dynamicLinkEventArgs = args as ReceivedDynamicLinkEventArgs;
        Debug.LogFormat("Received dynamic link {0}",
            dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString);
            debugText.text = dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString;
    }
}

The dynamic link opens the app but I don't get any callback. I also tried using the link while the app was open in the background but still did not get a callback. I'm assuming it is the same problem as novavision. Using 6.2.2

DooblyNoobly commented 5 years ago

@cynthiajoan fixed!

I had missed this part:

  1. Copy the dynamic links domain for your project under the Dynamic Links tab of the Firebase console e.g xyz.app.goo.gl and assign it to the string DynamicLinksDomain on the UIHandler object in the MainScene.

So not sure what you were mentioning there but I had to add custom links to plist.info as per: image

I edited the plist file, made a key and array value with my links in it and it worked. I'm using a custom domain and not a link.page domain so this is probably why I had problems. Maybe that was the same for @novavision

novavision commented 5 years ago

@DooblyNoobly I used custom domain as well, and may be that was the problem. Anyway there were 2 more big issues related to Dynamic Links:

  1. You can't crab custom parameters from a short link, what actually makes the general idea of deep links useless.
  2. If app is not installed and user follow the link, he will see another screen in Safari/Android def browser and will be asked to click to open the store to download the app. The link starts with "preview.CustomDomain". I didn't find a way to avoid it
DooblyNoobly commented 5 years ago

@novavision:

  1. You can't crab custom parameters from a short link, what actually makes the general idea of deep links useless.

You need to url encode a url compatible string that goes into the link query of a dynamic link if you want to send custom parameters. Make a link that will also work in the browser along with your apps and then run it through URL Encode using UTF8 encoding. You then pass that to the ?link= query. And then construct your previews and fallback links with the dynamic link components provided in the firebase lib (Check the sample posted by @cynthiajoan).

novavision commented 5 years ago

Unfortunately, I didn't understand how URL encoding will help to parse Firebase short link generated on a server side? Furthermore, I can't understand why this info is not described on the official page.

patm1987 commented 5 years ago

Hi everybody!

I'm sorry that y'all have had a bad experience. I want to do two things before I close up this bug.

First: can I verify that the original issue is fully resolved. The DynamicLinkReceived not being called?

Second: I would love to capture the feedback you have about the documentation in an actionable way. As y'all are clearly expressing, a difficult to understand SDK is just as bad as a broken SDK. Either let us know here: https://firebase.google.com/support, saying "hey, I tried to do x, but it was unclear" Or make sure that I'm getting the right actionable feedback from y'all: You both suffered from missing one piece of information on editing the Info.plist and @novavision would've hugely benefitted from an explicit piece of documentation on retrieving custom parameters.

Sorry about the confusion/frustration! --Patrick

stewartmiles commented 5 years ago

Since we haven't heard from you all, we'll assume that your setup issue is resolved.