Coder Social home page Coder Social logo

Comments (29)

priyarishi avatar priyarishi commented on September 14, 2024 1

@Ghevi I am running it from windows pc. Dont have a mac I am afraid :( . It works fine in simulator.
if it was a .plist issue why would it work in simulator. Any more suggestions would be highly appreciated.

from plugin.firebase.

tranb3r avatar tranb3r commented on September 14, 2024 1

I have the GoogleService-Info.plist in the root folder of the project (maybe it can go in the platforms/ios one?)

Here is how I do it:
<BundleResource Include="Platforms\iOS\GoogleService-Info.plist" Link="GoogleService-Info.plist" />

from plugin.firebase.

tegrityllc avatar tegrityllc commented on September 14, 2024

Same. Appears the launchOptions are always null.

from plugin.firebase.

RomanDrechsel avatar RomanDrechsel commented on September 14, 2024

I have the same problem.
Is there any fix yet?

from plugin.firebase.

TobiasBuchholz avatar TobiasBuchholz commented on September 14, 2024

If anyone could provide a sample project that contains this issue I will take a look, thanks✌️

from plugin.firebase.

RomanDrechsel avatar RomanDrechsel commented on September 14, 2024

MAUIiOS.zip

This is a simple sample project, i tested it and have the same issue.
(i deleted the GoogleService-Info.plist)

from plugin.firebase.

TobiasBuchholz avatar TobiasBuchholz commented on September 14, 2024

Thanks @Shalafi280438, but unfortunately I'm not able to install your project onto my iOS simulator with the following error:

/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch --launchsim /Users/tobiasbuchholz/Downloads/MAUIiOS/MAUIiOS/bin/Debug/net6.0-ios/iossimulator-x64/MAUIiOS.app --device=:v2:udid=B069F1E3-DBE7-4296-9C8E-A184C4F5B913 -sdk 15.4 --argument=-monodevelop-port --argument=10000 --setenv=XAMARIN_DEBUG_PORT=10000 --sdkroot /Applications/Xcode.app/Contents/Developer
An error was encountered processing the command (domain=IXUserPresentableErrorDomain, code=4):
„MAUIiOS“ muss aktualisiert werden.
Diese App muss vom Entwickler aktualisiert werden, um mit dieser iOS-Version zu funktionieren.
Failed to find matching arch for input file: /Users/tobiasbuchholz/Library/Developer/CoreSimulator/Devices/B069F1E3-DBE7-4296-9C8E-A184C4F5B913/data/Library/Caches/com.apple.mobile.installd.staging/temp.zijBk1/extracted/MAUIiOS.app/MAUIiOS
Underlying error (domain=MIInstallerErrorDomain, code=15):
Failed to find matching arch for input file: /Users/tobiasbuchholz/Library/Developer/CoreSimulator/Devices/B069F1E3-DBE7-4296-9C8E-A184C4F5B913/data/Library/Caches/com.apple.mobile.installd.staging/temp.zijBk1/extracted/MAUIiOS.app/MAUIiOS
error HE0046: Failed to install the app 'com.allinklcom.mauiios' on the device 'iOS 15.4 (19E240) - iPhone 13': simctl returned exit code 4

The error occurs with Visual Studio for Mac and also with Rider. Any idea what could cause this?

@tegrityllc Apparently the launchOptions are always null and don't cause any problems, at least that's the case for my projects. I've noticed in the .csproj file of @Shalafi280438's project that the GoogleService-Info.plist is located in Platforms\iOS\GoogleService-Info.plist. As far as I've tried it, this won't work, so you'll have to put the GoogleService-Info.plist in the root folder of the application like I've mentioned in the README. Maybe that's the problem?

from plugin.firebase.

RomanDrechsel avatar RomanDrechsel commented on September 14, 2024

Maybe you can't install the project because it is created with the new Preview-version of Visual Studio?

I always read that the plist must be placed in the Platforms Folder, but i will try next week when i'm in office again ;)

from plugin.firebase.

RomanDrechsel avatar RomanDrechsel commented on September 14, 2024

It still doesn't work.
I tried to use Firebase on an Xamarin.Forms App with the Plugin.FirebasePushNotification Package, but on iOS i got nearly the same error.

Is it normal that i got several errors while starting the app?

`2022-10-05 14:45:33.558 Xamarin.PreBuilt.iOS[1108:205729] Could not resolve assembly Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/C3D0D3F9-2A14-459F-9967-2B393CF3D511/Documents/AIMessenger.content/Microsoft.VisualStudio.DesignTools.TapContract.dll' or one of its dependencies.

2022-10-05 14:45:33.562 Xamarin.PreBuilt.iOS[1108:205729] Could not resolve assembly Xamarin.HotReload.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/C3D0D3F9-2A14-459F-9967-2B393CF3D511/Documents/AIMessenger.content/Xamarin.HotReload.Contracts.dll' or one of its dependencies.

Resolved pending breakpoint for 'Xamarin.HotReload.HotReloadAgent.BreakpointSendToIde(System.String)' to D:\a_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:419 [0x00000].
2022-10-05 14:45:33.823 Xamarin.PreBuilt.iOS[1108:205729] Could not resolve assembly Xamarin.HotReload.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/C3D0D3F9-2A14-459F-9967-2B393CF3D511/Documents/AIMessenger.content/Xamarin.HotReload.Contracts.dll' or one of its dependencies.

2022-10-05 14:45:33.824 Xamarin.PreBuilt.iOS[1108:205729] Could not resolve assembly Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/C3D0D3F9-2A14-459F-9967-2B393CF3D511/Documents/AIMessenger.content/Microsoft.VisualStudio.DesignTools.TapContract.dll' or one of its dependencies.

Resolved pending breakpoint for 'Xamarin.HotReload.HotReloadAgent.BreakpointCheckpoint()' to D:\a_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:414 [0x00000].`

from plugin.firebase.

balazs-adam avatar balazs-adam commented on September 14, 2024

I believe the problem is that Firebase app itself is not getting initialized. I've tried to run the sample initializing the cloud messaging only (new CrossFirebaseSettings(isCloudMessagingEnabled: true)). Doing so throws the following exception:

[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: '   at Plugin.Firebase.CloudMessaging.FirebaseCloudMessagingImplementation.RegisterForRemoteNotifications() in C:\Source\Plugin.Firebase\src\iOS\CloudMessaging\FirebaseCloudMessagingImplementation.cs:line 29
   at Plugin.Firebase.CloudMessaging.FirebaseCloudMessagingImplementation.Initialize() in C:\Source\Plugin.Firebase\src\iOS\CloudMessaging\FirebaseCloudMessagingImplementation.cs:line 21
   at Plugin.Firebase.iOS.CrossFirebase.Initialize(UIApplication app, NSDictionary options, CrossFirebaseSettings settings, Options firebaseOptions, String name) in C:\Source\Plugin.Firebase\src\iOS\CrossFirebase.cs:line 38
   at Playground.MauiProgram.<>c.<RegisterFirebaseServices>b__2_8(UIApplication app, NSDictionary launchOptions) in C:\Source\Plugin.Firebase\sample\Playground\MauiProgram.cs:line 70
   at Microsoft.Maui.MauiUIApplicationDelegate.<>c__DisplayClass6_0.<FinishedLaunching>b__0(FinishedLaunching del)
   at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[FinishedLaunching](IServiceProvider services, Action`1 action)
   at Microsoft.Maui.MauiUIApplicationDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at Playground.Program.Main(String[] args) in C:\Source\Plugin.Firebase\sample\Playground\Platforms\iOS\Program.cs:line 12
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)'

If the Firebase app is not initialized properly (calling the Firebase.Core.App.Configure method) then the following Messaging.SharedInstance reference will throw NRE:

I think the problem is with the underlying Xamarin.Firebase.iOS.Core nuget itself as reported here:
xamarin/GoogleApisForiOSComponents#577

from plugin.firebase.

RomanDrechsel avatar RomanDrechsel commented on September 14, 2024

So is there a workaround or something to get it working?

from plugin.firebase.

nodoid avatar nodoid commented on September 14, 2024

from plugin.firebase.

Ghevi avatar Ghevi commented on September 14, 2024

Hi I also experience the same issue. I'm trying to deploy the app to a phisical device.
This exception happens both on windows machine and mac.
Another example of how to implement push notifications on ios is this one but in the readme it says that this only works on release.
It's the first time I implement push notifications on iOS, do you guys have any suggestion for doing it without any package?
I tried implementing it natively but it seems the necessary methods aren't called at all.

from plugin.firebase.

Ghevi avatar Ghevi commented on September 14, 2024

Ok so after some tries with the link i provided in the comment above, i managed to make notifications works on iOS device even in debug.
The firebase options initialization throws exception on Windows machine but it works on Mac!
The package Xamarin.Firebase.iOS.CloudMessaging that it's used in that repo for some reason gave me some missing resource error.
So i'm still using the Plugin.Firebase package as of this repo but I'm following the code example i mentioned above.

from plugin.firebase.

elprofesor0710 avatar elprofesor0710 commented on September 14, 2024

Any workaround on this issue? can you please let me know?

from plugin.firebase.

elprofesor0710 avatar elprofesor0710 commented on September 14, 2024

I'm still getting error using macOS: Terminating app due to uncaught exception 'System.NullReferenceException', reason: 'Object reference not set to an instance of an object. (System.NullReferenceException)
at Plugin.Firebase.Auth.FirebaseAuthImplementation.Initialize

Anyone how to fix this issue? please help

from plugin.firebase.

elprofesor0710 avatar elprofesor0710 commented on September 14, 2024

anyone knows how to fix this issue???please help!

from plugin.firebase.

TobiasBuchholz avatar TobiasBuchholz commented on September 14, 2024

Hi @elprofesor0710, what do you mean by:

I'm still getting error using macOS: ...

Are you targetting macOS or do you mean that you are running the project on a mac? Targetting macOS is not supported by the plugin.

Did you put the GoogleServices-Info.plist and google-services.json files in the project root and referenced them correctly in your .csproj file as described in the readme? Or can you provide a sample project that showcases the problem?

from plugin.firebase.

priyarishi avatar priyarishi commented on September 14, 2024

@elprofesor0710 @Ghevi @balazs-adam @Shalafi280438 Facing same issue while running the MAUI App on ios Device.
Crashes at CrossFirebase.Initialize(app, launchOptions, CreateCrossFirebaseSettings()); with NULL Reference Exception.
Anyone got workaround? Urgent

from plugin.firebase.

Ghevi avatar Ghevi commented on September 14, 2024

@priyarishi Are you launching the app from a windows pc? Try on mac and if the issue persist it something about the GoogleServices-Info.plist i think. I remember having that error but i forgot what was the issue :(

Sorry removed the code snippet cause i found an unrelated bug lol

from plugin.firebase.

priyarishi avatar priyarishi commented on September 14, 2024

@Ghevi Can you by any chance share the ios Specific code you had in the events. Did you try running this on a physical device?

from plugin.firebase.

Ghevi avatar Ghevi commented on September 14, 2024

Sorry if this is kind of a mess, im still new to mobile development anyway yes this code work on physical device and the app has been accepted to the appStore.

Tips are welcome ;)

using Firebase.CloudMessaging;
using Foundation;
using UIKit;
using UserNotifications;

namespace MyApp;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate, 
    IAppDelegate, 
    IUNUserNotificationCenterDelegate,
    IMessagingDelegate
{
    protected override MauiApp CreateMauiApp()
    {
        return MauiProgram.CreateMauiApp();
    }

    public override Boolean FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        var result = base.FinishedLaunching(application, launchOptions);

        var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
        UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
        {
            Log($"RequestAuthorization: {granted}" + (error != null ? $" with error: {error.LocalizedDescription}" : string.Empty));

            if (granted && error == null)
            {
                this.InvokeOnMainThread(() =>
                {
                    UIApplication.SharedApplication.RegisterForRemoteNotifications();
                    try
                    {
                        var options = new Firebase.Core.Options(
                            "your googleAppId",
                            "your gmcSenderId");
                        options.ApiKey = "your api key";
                        options.ProjectId = "your project id";
                        options.BundleId = "your bundle id";
                        options.ClientId = "your client id";

                        Firebase.Core.App.Configure(options);
                    }
                    catch (Exception x)
                    {
                        Log("Firebase-configure Exception: " + x.Message);
                    }

                    UNUserNotificationCenter.Current.Delegate = this;

                    if (Messaging.SharedInstance != null)
                    {
                        Messaging.SharedInstance.Delegate = this;
                        Log("Messaging.SharedInstance SET");
                    }
                    else
                    {
                        Log("Messaging.SharedInstance IS NULL");
                    }
                });
            }
        });

        return result;
    }

    [Export("application:didFailToRegisterForRemoteNotificationsWithError:")]
    public void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
    {
        Log($"{nameof(FailedToRegisterForRemoteNotifications)}: {error?.LocalizedDescription}");
    }

    [Export("messaging:didReceiveRegistrationToken:")]
    public void DidReceiveRegistrationToken(Messaging messaging, String fcmToken)
    {
        Log($"{nameof(DidReceiveRegistrationToken)} - Firebase token: {fcmToken}");
    }

    [Export("userNotificationCenter:willPresentNotification:withCompletionHandler:")]
    public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
    {
        var userInfo = notification.Request.Content.UserInfo;
        Log($"{nameof(WillPresentNotification)}: " + userInfo);
        MessagingCenter.Send(this, nameof(WillPresentNotification), userInfo);
        completionHandler(UNNotificationPresentationOptions.Alert);
    }

    [Export("userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:")]
    public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
    {
        Log($"{nameof(DidReceiveNotificationResponse)}: " + response.Notification.Request.Content.UserInfo);
        MessagingCenter.Send(this, nameof(DidReceiveNotificationResponse), response.Notification.Request.Content.UserInfo);
        completionHandler();
    }

    static void Log(String msg)
    {
        System.Diagnostics.Debug.WriteLine(msg);
    }
}

from plugin.firebase.

priyarishi avatar priyarishi commented on September 14, 2024

@Ghevi Still facing the same issue.
[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.Firebase.Auth.FirebaseAuthImplementation.Initialize(UIApplication application, NSDictionary launchOptions, String facebookAppId, String facebookDisplayName)
at Plugin.Firebase.iOS.CrossFirebase.Initialize(UIApplication app, NSDictionary options, CrossFirebaseSettings settings, Options firebaseOptions, String name)

from plugin.firebase.

priyarishi avatar priyarishi commented on September 14, 2024

@elprofesor0710 Were you able to resolve the issue. Can you please give some details. I am getting the error on ios device and simulator works fine.

from plugin.firebase.

Ghevi avatar Ghevi commented on September 14, 2024

@priyarishi I tried again today and from a windows pc with iPhone device, the code i gave you works except for when it tries to create the Firebase Options, which is different from your issue.
I have the GoogleService-Info.plist in the root folder of the project (maybe it can go in the platforms/ios one?) and in .csproj i have this code:

     <ItemGroup>
           <PackageReference Include="Plugin.Firebase" Version="1.2.1" />
     </ItemGroup>

    <ItemGroup Condition="'$(TargetFramework)' == 'net6.0-ios'">
        <BundleResource Include="GoogleService-Info.plist" />
    </ItemGroup>

from plugin.firebase.

priyarishi avatar priyarishi commented on September 14, 2024

@Ghevi @tranb3r Thanks so much for responding. I have tried to move the GoogleService-Info.plist the way you specified and also the bundleresource tag . But the same issue happens.
My Plugin.Firebase version is 1.2.5 (latest one). I revered it to the version you have 1.2.1. But the same issue.
I have attached my sample project . If you guys could check what am I missing and if it works on your end. I have removed the GoogleService Info files for now. Please let me know if thats fine.

You will see some commented code in the AppDelegate.cs file. I have tried the commented code as well. Same error occurs.
Would be great if you could use this project to run on your device. This will run with just one button on MainPage.xaml which calls the Google SSO.

I need to use this Plugin just to login using Google and nothing else ( no messaging or notifications are needed for the project).
Thanks
SSOMAUI.zip

from plugin.firebase.

Ghevi avatar Ghevi commented on September 14, 2024

@priyarishi ah dang im sorry, i thought you were using it for the cloud messaging. My bad. Hopefully someone else can helo you. I have no experience with the google authentication.

from plugin.firebase.

priyarishi avatar priyarishi commented on September 14, 2024

@Ghevi No Problem. I should have clarified this before I guess. But according to me the Firebase Auth initialization happens in all the cases. if its for the sso or messaging.

from plugin.firebase.

TobiasBuchholz avatar TobiasBuchholz commented on September 14, 2024

Since I haven't heard from you in more than 30 days, I hope this issue is no longer affecting you. If it is, please reopen this issue and provide the more information so that I can look into it further. Thank you!

from plugin.firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.