Firebase dynamic link is not resolving in Xamarin Forms iOS - firebase

I am using Xamarin.Firebase.iOS.DynamicLinks 2.3.1.1 for dynamic links, Earlier it was working fine but recently it is not working. While trying to extract the short link, long link getting null. Is anyone knows why it is not working?
I have updated to the latest version (4.0.1) and its working fine. It not working any of the previous version of NuGet packages.

To answer your question. The Dynamic links are not working either on Firebase's end who choose to discontinue their old library or due to the newest IOS update 13.3. I say this because my app that is in production had its links working fine then they suddenly stopped working.
My current solution was to update Xamarin.Firebase.iOS.DynamicLinks to (4.0.1) and I was able to once again process the long url with its parameters.
A few things to note if you have other libraries such as Firestore, Analytics, Notifications etc.
You might run into linker failed exceptions. They occur because
Xamarin.Firebase.iOS.DynamicLinks (3.0.2.1) and prior depended on
Xamarin.Firebase.iOS.Core (>= 5.1.3) and the working
Xamarin.Firebase.iOS.DynamicLinks (4.0.1.1) references
Xamarin.Firebase.iOS.Core (>= 6.1.0.1) Somehow they reference methods that are no longer available.
The linking failed is fixed by checking each of your nuGets and manually installing their respective nuGets that reference ...iOS.Core (>= 6.1.0.1) : For example:
if you use Xamarin.Firebase.iOS.Storage (2.0.0) manually install
Xamarin.Firebase.iOS.Storage (3.4.0.1) because
Xamarin.Firebase.iOS.Storage (2.0.0) references
Xamarin.Firebase.iOS.Storage (>= 3.0.2) which in turn references:
Xamarin.Firebase.iOS.Core (>= 5.1.3) and it will cause native linking failed
And lastly, in my case Xamarin.Firebase.iOS.DynamicLinks (4.0.1.1) will make your method for generating ShortLinks, stop working too:
In Xamarin.Firebase.iOS.DynamicLinks (3.0.2.1) you would build your
DynamicLinkComponents with:
var shareLink = DynamicLinkComponents.FromLink(linkParameters,
"YOUR_DOMAIN.page.link");
Xamarin.Firebase.iOS.DynamicLinks (4.0.1.1) recomends you use
DynamicLinkComponents.Create(YOURlinkParameters, "YOUR_DOMAIN.page.link");
but it would return a null DynamicLinkComponents so i fixed by doing:
var shareLink = new DynamicLinkComponents();
shareLink.Link = YOURlinkParameters;
shareLink.Domain = "https://YOUR_DOMAIN.page.link";
I spent a week trying to troubleshoot this error and really hope others are able to see this and save you valuable time.

A work around to get Xamarin.Firebase.iOS.DynamicLinks 3.0.2.1 working (should work on 2.3.1.1 as well) is to have the IOS device open the link in the browser which will then redirect them back to the app.
The flow is Dynamic link > App [short link] > Browser > App with [long link].
Dynamic links are formatted "domain.page.link/ShortSequence" and long links parameters have "domain.page.link/?". You can look for the '?' to decide weather to process url or to redirect user as follows:
public override bool ContinueUserActivity(UIApplication application,
NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
if (userActivity.ActivityType == NSUserActivityType.BrowsingWeb)
{
var sharedLink = userActivity.WebPageUrl;
if (!sharedLink.ToString().Contains("domain.page.link/?")){
await Launcher.OpenAsync(new Uri(sharedLink.ToString()));
return;
}
var handled = DynamicLinks.SharedInstance.FromUniversalLinkUrl(sharedLink);
//Process your DynamicLink parameters
}
return true;
}

Related

Issue: Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform

I started a new project in vue.js. I added navbar. At one point, I noticed issue in the console:
Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform
I don't understand this, because I don't use any navigator in the project.
Why am I seeing this issue? How can I change it?
The reason one sees the message is well explained in the description of the very same message (audit).
The real question is who/what is the source of it. There is a hint to the file extended-css.js.
Here is an example with another file (as I do not have the extended-css.js):
Right click on the file and then choose Open in new tab.
So there you can see that the reason for the audit message is the hook.js file from the Vue.js devtools extension.
In your case it would be another extension or library you are using - direct or indirect (for example a part of vuetify, etc.).
From there you have 3 choices:
ignore it
wait for the authors of the library to fix the issue and update it
disable the extension/remove the library causing it.
https://blog.chromium.org/2021/05/update-on-user-agent-string-reduction.html
Is helpful to read. Some key points:
"Beginning in M92, we plan to start sending deprecation notices for the navigator.userAgent,
navigator.appVersion, and navigator.platform getters in the DevTools Issues tab."
"If your site, service, library or application relies on certain bits of information being present in the User Agent string such as Chrome minor version, OS version number, or Android device model, you will need to begin the migration to use the User Agent Client Hints API instead."
I know I am not using the navigator getters in question so at this point, it seems I can only wait for an update to the library's .js
(in my case, bootstrap 4) to make the warning go away.

Unity Firebase Crashlytics not sending any crash reports, getting "failed to retrieve settings" error on logcat

Unity editor version: 2019.3.15f1
Firebase Unity SDK version: firebase_unity_sdk_6.15.2
Additional SDKs im using: Unity IAP, Gamesparks, Ironsource, Facebook, Appsflyer, GameAnalytics
Platform im using the Unity editor on: Windows
Platform im targeting: Android
Scripting Runtime: IL2CPP
Problem
I am getting data on firebase analytics, but I cannot get crashlytics to report anything. Im stuck on this...
Steps to reproduce:
Add the firebase analytics and crashlytics sdks.
Add the google-services.json GoogleService-Info.plist files somewhere in assets folder
Add this code to initialise the firebase
// Use this for initialization
void Start ()
{
// Initialize Firebase
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your application class.
// Crashlytics will use the DefaultInstance, as well;
// this ensures that Crashlytics is initialized.
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
// Set a flag here for indicating that your project is ready to use Firebase.
VisualDebugger.SetText("crashlytics initialised");
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}",dependencyStatus));
VisualDebugger.SetText("crashlytics NOT initialised: " + dependencyStatus);
// Firebase Unity SDK is not safe to use here.
}
});
Invoke("IsCrashEnabled", 5f);
}
void IsCrashEnabled()
{
VisualDebugger.AddLine("IsCrashlyticsCollectionEnabled: "+Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled);
}
In order to get the app to run with the facebook sdk installed Ive added these two lines to proguard-user.txt
-keep public class com.facebook.**{public *; }
-keep public class com.facebook.internal.**{ public *; }
and commented out the following lines from mainTemplate.gradle
//implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
When I run the app, firebase is initialised successfully. Also Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled returns true.
I crash the app in a number of different ways, then open it again without reinstalling. But no crash reports are sent.
When I watch logcat when starting the app I see this error from firebase each time the app is opened
2020-09-28 16:18:59.332 25773-25847/? E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/REDACTEDblahblahblah/settings
Update Oct 19, 2020:
Today a developer updated the issue I linked in this answer saying the Firebase team fixed a backend bug last Friday (Oct 16) that was affecting some new Unity Android apps registering w/ Firebase - likely the bug behind your issue. I had already solved the issue in my own project using the below solution, but if you haven't yet updated your project, I recommend running it again and seeing if Crashlytics is working for you now..
I've been dealing with the same issue this week in Unity 2019.4.11f1 - i see the same error message about not being able to retrieve settings, but with my specific project and appIds in the URL.
I found a solution in this Github issue, which suggests the problem is caused by the version of an android library that is a dependency for the Unity Firebase Crashlytics package. My rough understanding is that the firebase-crashlytics-unity library is a wrapper around android library firebase:firebase-crashlytics, and the unity package allows the underlying native Android code to be used from Unity. Version com.google.firebase:firebase-crashlytics:17.10.0 has issues with getting the settings for some Firebase projects on Android. Myself and several others following this issue found forcing Unity to use this specific dependency at version 17.1.1 resolved the issue.
Someone else with the same issue in the thread contacted Firebase support and was told:
The error you are seeing "Failed to retrieve settings" is related to
the SDK version being used. If you go to "Assets > Firebase > Editor>
CrashlyticsDependencies" you can manually update the SDK to point to
the latest Crashlytics SDK version 17.2.2. Please give it a try and if
you continue having issues, let me know.
It turned out this advice wasn't quite right - some of us following the thread then experienced a different issue when using the Android Crashlytics SDK version 17.2.2 with Unity crashlytics version 6.16.0. So I'd specifically recommend trying out the below suggestion or other solutions in the thread to set your Android crashlytics library to v17.1.1.
Changes I made in my project to address this:
First, I updated my unity firebase packages in the package manager to use version 6.16.0. In my project 4 packages were installed - core, analytics, crashlytics, and messaging.
Then I searched for the the Crashlytics package's dependency file - Crashlytics-Dependencies.xml (found by searching project - was in /Library/PackageCache/com.google.firebase.crashlytics#6.16.0/Firebase/Editor/ for me). This file initally had "com.google.firebase:firebase-crashlytics:17.0.0" listed, which I updated to be: "com.google.firebase:firebase-crashlytics:17.1.1".
As an extra precaution, I also added created a MyProject-Dependencies.xml file, as was suggested by a user in the thread - this file also specifies version "com.google.firebase:firebase-crashlytics:17.1.1".
Next, I modified the Unity build process to use a custom mainTemplate.gradle file to specify dependencies,
rather than using the External Dependency Resolver to manage and
embed unity packages (option in Build Settings > PlayerSettings >
Android).
I also updated the settings on the External Dependency Manager Android Ressolver:
Disabled AutoResolve and Disabled Resolve on Build (we dont want EDM updating dependencies without our knowledge when building)
I also turned disabled AndroidPackageInstallationEnabled - this has made the resolution process much faster and removed a bunch of .aar files from the android dependencies list, and hasn't caused any problems in my project.
I then ran External Dependency Resolver > Android > Force Resolve, which after the settings changes above, should now embed a list of the dependencies for the Android build into the mainTemplate.gradle file - Check this file (its in Assets/Plugins/Android) and you should now see com.google.firebase:firebase-crashlytics:17.1.1 in that list.
Also, I recommend reading this article about managing Unity Firebase dependencies from one of the Firebase developer advocates, Patrick Martin. It helped me wrap my head around how Android dependency management in Unity works, as well as how the Android gradle build process works.

SQLite no longer seems to work on xamarin android

We have a Xamarin.Forms project that needed to use the sqlite local db to store date. EF Core's sqlite library was used to set this up and by different developers from different PCs (vs 2019). Initially, it was used with the Database.EnsureCreated() function and later with ef core's migrations. All went smooth for more than a month.
Last week all of a sudden the android app wouldn't start on any one's PC due to some error with sqlite. It showed the following error:
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
I spent a while trying all kinds of fixes and rollbacks thinking it was an issue with the code. This included the following:
Deleted obj and bin folders, cleaned and rebuilt for all below steps.
Downgraded the version of ef to 2.2.3 (the version we started with)
Rolled back to git commits up to a week back
Upgraded the versions of dependencies of ef core
Removed the past few migrations
Downgraded xamarin forms to 3.6.x
After trying the above and several other fixes, finally upgrading the versions of java and android SDK worked last Friday (on all PCs). Once this fix worked everything went smooth that day. On Tuesday once again the issue was back (no library updates or code changes). A deeper look at EF Cores logging shows that it crashes the moment it attempts to connect to a db.
The issue can be replicated on the android devices but not the emulators. I am not sure if there is some new permission in android we need to request for.
I finally created a new xamarin forms project with sqlite setup. I used the pcl library and ef core. I still found the same error.
Here is the git hub that replicates the issue https://github.com/neville-nazerane/xamarin-site
Update
Just something i noticed. eariler my database file was named "main.db". Now no matter what i change this file name to or no matter what variables i change. it always shows database name as "main" in logs. Not sure if changing the db name would fix the issue. However, never found a way to change this db name. I tried different connection strings, it just said "database" and "db" were unknown keys
Update
Steps to replicate:
using (var db = new AppDbContext())
{
db.Add(new Person {
Age = 55,
Name = "Neville"
});
db.SaveChanges();
Person[] alldata = db.People.ToArray();
}
The definitions of Person and AppDbContext are quite obvious. So, with the spirit of not making the question too long, I am not posting it here. However, if required I can post them too.
This is a bug with the Xamarin.Forms and Mono.
It was detected since a couple of months ago, it was fixed but then there was some regression (with VS 2019 v16.1).
Even with the latest release (v16.1.2) the bug still happens, so we need to wait for a fix.
Sources:
https://github.com/mono/mono/issues/14170
https://github.com/xamarin/xamarin-android/issues/3112
https://github.com/xamarin/xamarin-android/issues/2920
Due to slight differences of the particular file systems on the native side, I would suggest creating an interface to handle the actual database file handling on the native application level.
So here is how I implemented SQLite using the nuget package SQLite.Net-PCL:
In the shared project, create a new interface, for instance FileHandler.cs
public interface IFileHandler
{
SQLite.SQLiteConnection GetDbConnection();
}
You may want to extend that with more methods to save or retrieve various files, but for now we will just have the GetDbConnection Method to retrieve a working SQLite Connection.
Now in your Android implementation, we add the native implementation to that interface:
Create a new class called FileHandler.cs in your android project:
[assembly: Dependency(typeof(FileHandler))]
namespace YourProjectName.Droid
{
public class FileHandler : IFileHandler
{
public SQLite.SQLiteConnection GetDbConnection()
{
string sqliteFilename = "YourDbName.db3";
string path = Path.Combine(GetPersonalPath(), sqliteFilename);
SQLiteConnectionString connStr = new SQLiteConnectionString(path, true);
SQLiteConnectionWithLock connection = new SQLiteConnectionWithLock(connStr, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.NoMutex);
return connection;
}
private string GetPersonalPath()
{
return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
}
}
Now back again in your shared code you can access that connection with the following code:
using (SQLiteConnection connection = DependencyService.Get<IFileHandler>().GetDbConnection())
{
// Do whatever you want to do with the database connection
}
Alright mate, I don't understand what issue you are facing. It might be an issue with your machine, I'd suggest using another computer/laptop.
I took the exact code that you shared on the Github. I was able to build it on my Mac computer in VS 2019 and installed the application in debug mode on my phone. I was able to add a date successfully, as you can see in the picture, and I placed an Exception Catchpoint and faced no exceptions.
I then proceeded to add another entry with the same details and it errored out with the message that you can see here
I would also suggest using Xamarin Profiler or any other Android logger to see the Stack Trace that you aren't able to see in your application output. It will give you details of the error, that you can share here for us to understand better.

Lightweight Rendering Pipeline error

I downloaded the lightweight rendering pipeline using Unity's package manager, but I cannot create a lightweight pipeline asset. When I try to create the asset, the console throws me:
Invalid generated unique path 'ProjectSettings/LightweightAsset.asset'
(input path
'LightweightAsset.asset')UnityEngine.Experimental.Rendering.LightweightPipeline.LightweightPipelineAsset:CreateLightweightPipeline()
I had a similar issue but it went away after I did the following:
Using the new package manager: Remove all rendering-related packages from the Unity project and then only add the Lightweight
Rendering Pipeline package. All dependencies (like the Shader Graph) were
added automatically and correctly after I did that.
Be sure to get the newest preview release (1.1.5-preview or newer). The 0.1-releases are too old.
If all else fails, try to follow the instructions and clone it directly from the Github repository: https://github.com/Unity-Technologies/ScriptableRenderPipeline

Qt Installer Framework: Auto Update

I'm currently using the Qt Installer Framework and managed to set up an online repository. What I want to know is:
Does the Framework provide some kind of "auto-update" mechanism, e.g. a plugin/service that checks for updates every time the program/system starts?
Check for updates would be enough, since the installation itself can be done using the maintanance tool.
All I could find about this topic was this small sentence:
End users can use the maintenance tool to install additional components from the server after the initial installation, as well as to receive automatic updates to content as soon as the updates are published on the server.
from here: http://doc.qt.io/qtinstallerframework/ifw-overview.html#choosing-installer-type
Thanks for your help!
Edit: Suggestion
Based on this question's accepted answere I created a small library to automatically check for updates using the installer framework - https://github.com/Skycoder42/QtAutoUpdater
What I do, is run the maintenance tool using QProcess, and then check the output. It has a mode where it doesn't run the GUI but only outputs update information if available.
Note that I set the working directory to the application's path when the applications starts, so I can just run maintenancetool.
QProcess process;
process.start("maintenancetool --checkupdates");
// Wait until the update tool is finished
process.waitForFinished();
if(process.error() != QProcess::UnknownError)
{
qDebug() << "Error checking for updates";
return false;
}
// Read the output
QByteArray data = process.readAllStandardOutput();
// No output means no updates available
// Note that the exit code will also be 1, but we don't use that
// Also note that we should parse the output instead of just checking if it is empty if we want specific update info
if(data.isEmpty())
{
qDebug() << "No updates available";
return false;
}
// Call the maintenance tool binary
// Note: we start it detached because this application need to close for the update
QStringList args("--updater");
bool success = QProcess::startDetached("maintenancetool", args);
// Close the application
qApp->closeAllWindows();
In the latest Qt Installer Framework 4.1 --checkupdates returns nothing, use ch or check-updates instead.
Commands:
in, install - install default or selected packages - <pkg ...>
ch, check-updates - show available updates information on maintenance tool
up, update - update all or selected packages - <pkg ...>
rm, remove - uninstall packages and their child components - <pkg ...>
li, list - list currently installed packages - <regexp>
se, search - search available packages - <regexp>
co, create-offline - create offline installer from selected packages - <pkg ...>
pr, purge - uninstall all packages and remove entire program directory
I just found a pretty nice implementation on GitHub:
https://github.com/ioriayane/TheArtOfQt2/blob/master/src/HelloWorld/maintenancetool.cpp
It takes care of handling Windows, MacOS and Linux. + It is written to use in QML / Qt Quick bindings (+ example).
It has some Japanese comments, but is Apache 2.0 licensed, so freely to use (following Apache 2.0 requirement).
There's a section in the guide about how to do it, but they call it promoting updates rather than auto updates, IFW Updates on doc.qt.io.

Resources