TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
220 stars 49 forks source link

GoogleAppMeasurementIdentitySupport dependency is not currently linked #342

Closed rezamohamed closed 1 month ago

rezamohamed commented 1 month ago

Regarding Plugin.Firebase.Analytics:

(1) I see the following warning message when I run/debug my app, is this something that is a cause for concern?

10.24.0 - [FirebaseAnalytics][I-ACS044003] GoogleAppMeasurementIdentitySupport dependency is not currently linked. IDFA will not be accessible.

I've followed all the instructions to enable Analytics.

(2) I also see this message: 10.24.0 - [FirebaseAnalytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement

(3) Finally, I see the Analytics collection enabled message twice, could It be that I accidentally initializing twice?

10.24.0 - [FirebaseAnalytics][I-ACS023012] Analytics collection enabled 10.24.0 - [FirebaseAnalytics][I-ACS023220] Analytics screen reporting is enabled. Call Analytics.logEvent(AnalyticsEventScreenView, parameters: [...]) to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist 10.24.0 - [FirebaseAnalytics][I-ACS023012] Analytics collection enabled 10.24.0 - [FirebaseAnalytics][I-ACS023220] Analytics screen reporting is enabled. Call Analytics.logEvent(AnalyticsEventScreenView, parameters: [...]) to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist

AdamEssenmacher commented 1 month ago

Updating Firebase.Core to 10.24.0.3+ should fix this. You should be able to add it directly in your project if you don't want to wait for the next Plugin.Firebase update.

rezamohamed commented 1 month ago

I've upgraded Installations, do I need to upgrade the implicitly installed packages manually as well? I am using Auth, Firestore, Storage, and Analytics.

CleanShot 2024-10-15 at 19 08 34@2x

AdamEssenmacher commented 1 month ago

The GoogleAppMeasurement affected Firebase.Core and the fix was published with 10.24.0.3. So, as long as your package configuration uses Firebase.Core 10.24.0.3+, you should be good.

As a personal recommendation, I would suggest actively managing the native library dependencies (for both iOS and Android) for this plugin by directly including them in your project.

rezamohamed commented 1 month ago

When I manually upgraded AdamE.Firebase.iOS.Installations, it looks like the two implicitly installed nugets did not get updated. I will go ahead and install them manually and add them into my CSPROJ.

However, I have a few questions (1) right now I am using Auth, Firestore, Storage and Analytics. But it looks like the only other implicitly installed nugets are AdamE.Firebase.iOS.Core and AdamE.Firebase.iOS.Analytics. Does this mean Auth, firestore, storage are NOT using the AdamE nugets?

(2) peeking into the SRC folder of Auth here as an example, [Plugin.Firebase]/[src]/[Auth]/Auth.csproj I do see that there is an explicitly reference to version 10.24.0

    <ItemGroup Condition="'$(TargetFramework)' == 'net6.0-ios'">
        <PackageReference Include="AdamE.Firebase.iOS.Auth" Version="10.24.0" />
    </ItemGroup>

So if I install the 10.27.0 of Auth, would it get picked up? That is if I require it in the first place because it isn't in my project currently and works fine.

AdamEssenmacher commented 1 month ago

I don't quite understand your first question. A .csproj example might be more clear.

Regarding your second question, this is all just standard nuget package resolution stuff.

Let's say all you've done in your MAUI .csproj is include Plugin.Firebase.Firestore 3.0.0. If you check the dependencies under that link, you see "AdamE.Firebase.iOS.CloudFirestore (>= 10.24.0)". Note the '(>=10.24.0)', which means NuGet is going to resolve to 10.24.0 by default, but higher package versions can be used. Continuing this example, the native Firestore v10.25 includes a bug fix you could be interested in. There's really no reason for Plugin.Firebase to release a new package in this case (because no APIs have changed), so all you need to do to pick up that bug fix is directly include AdamE.Firebase.iOS.CloudFirestore 10.25+.

rezamohamed commented 1 month ago

This is my current csproj:

  <ItemGroup>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
    <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.91" />
    <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.91" />
    <PackageReference Include="Plugin.Firebase.Analytics" Version="3.0.0" />
    <PackageReference Include="plugin.firebase.auth" Version="3.0.0" />
    <PackageReference Include="plugin.firebase.firestore" Version="3.0.0" />
    <PackageReference Include="plugin.firebase.storage" Version="3.0.0" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
    <PackageReference Include="Xamarin.AndroidX.Activity" Version="1.9.0.4" />
    <PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.9.0.4" />
    <PackageReference Include="Xamarin.AndroidX.Browser" Version="1.8.0.3" />
    <PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.0.6" />
    <PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.0.5" />
    <PackageReference Include="Xamarin.AndroidX.Core" Version="1.13.1.3" />
    <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.4.0" />
    <GoogleServicesJson Include="Platforms\Android\google-services.json" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
    <PackageReference Include="AdamE.Firebase.iOS.Installations" Version="10.27.0" />
    <BundleResource Include="Platforms\iOS\GoogleService-Info.plist" Link="GoogleService-Info.plist" />
  </ItemGroup>

What I am asking is if I should see AdamE.Firebase.iOS.CloudFirestore (as an example for Firestore) in my Nuget list of installs, or at as an least implicitly installed package - which I currently don't, only see Plugin.Firebase.Core.

CleanShot 2024-10-16 at 15 27 29@2x

Given that AdamE.Firebase.iOS.CloudFirestore isn't in my nuget list, or implicitly installed, if I just Add AdamE.Firebase.iOS.CloudFirestore, would it get picked up by Plugin.Firebase.Firestore. I will then do the same for Auth, Storage, Analytics ...for the corresponding AdamE nuget if this is the case.

AdamEssenmacher commented 1 month ago

Plugin.Firebase.Firestore has a direct dependency on AdamE.Firebase.iOS.CloudFirestore--it's there. Perhaps you have a filter set? I suspect your project has more than 4 packages installed...

rezamohamed commented 1 month ago

Really weird, the project was working fine without the AdamE nugets, even implicitly in my project. I went ahead and removed all the Plugin.Firebase. nugets and re-added them and then each of the dependencies showed up as implicitly referenced. I updated to the 10.28.0 of all the AdamE. nugets and moved them into the net8.0-ios itemgroup.

I wanted to do the same to the Android Xamarin.Firebase.* dependencies, but this was harder because of all the references. Kept failing adding the new versions of the Android dependencies.

CleanShot 2024-10-16 at 23 48 02@2x

AdamEssenmacher commented 1 month ago

Really weird, the project was working fine without the AdamE nugets, even implicitly in my project.

I'm sure your project was working, but it's simply not possible to reference Plugin.Firebase 3.0.0 and not pick up the AdamE.* packages as transient dependencies. It's also not possible for this plugin to work on iOS without them.

The Android side can be a bit tricky, as the Xamarin.Firebase.* dependencies are intermixed with AndroidX dependencies. So, it's completely possible for the latest Firebase SDKs to be incompatible with other Android libraries you have installed--or even MAUI itself.

rezamohamed commented 1 month ago

No worries, I have the iOS working well now.

The Android updates might not be worth the effort. There are too many circular references, which is taking time to figure out. I'll stand down on updating Android.

I appreciate your help with this!