Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On IOS we get error when the application starts #1

Open
OroviaTraining opened this issue Oct 15, 2022 · 2 comments
Open

On IOS we get error when the application starts #1

OroviaTraining opened this issue Oct 15, 2022 · 2 comments

Comments

@OroviaTraining
Copy link

OroviaTraining commented Oct 15, 2022

Your project MauiFirebaseDemo/MauiFirebaseDemo/ does not work with IOS and I get the following error.
[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.Firebase.CloudMessaging.FirebaseCloudMessagingImplementation.RegisterForRemoteNotifications()
at Plugin.Firebase.CloudMessaging.FirebaseCloudMessagingImplementation.Initialize()
at Plugin.Firebase.iOS.CrossFirebase.Initialize(UIApplication app, NSDictionary options, CrossFirebaseSettings settings, Options firebaseOptions, String name)
at MauiFirebaseDemo.MauiProgram.<>c.b__1_3(UIApplication app, NSDictionary launchOptions) in C:\SourceCode\PlayGround\MauiFirebaseDemo\MauiProgram.cs:line 36
at Microsoft.Maui.MauiUIApplicationDelegate.<>c__DisplayClass6_0.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.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
at MauiFirebaseDemo.Program.Main(String[] args) in C:\SourceCode\PlayGround\MauiFirebaseDemo\Platforms\iOS\Program.cs:line 13
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)'
The app has been terminated.

I noticed, in this statement
CrossFirebase.Initialize(app, launchOptions, CreateCrossFirebaseSettings());
launchOptions is null

@glihm
Copy link

glihm commented Jan 26, 2023

Yup, we have the exact same issue. Importing the source code of the library, the field causing this is the Messaging.SharedInstance field which is null. This can be found here. This where the exception is raised.

Seems that also this field is readonly, so unable to initialize it by hand for testing purposes. The value is retrieved like this:
return Runtime.GetNSObject<Messaging>(ApiDefinition.Messaging.NativeHandle_objc_msgSend(class_ptr, Selector.GetHandle("messaging"))); from Objective-C code directly.

Are we missing something from the plateform initialization? Following your tutorial and using this repo or our code, same issue.

Any idea @cedricgabrang ?

@harima34
Copy link

Hi there, i got the same issue also, did you found how to solve this problem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants