CrossGeeks / FirebasePushNotificationPlugin

Firebase Push Notification Plugin for Xamarin iOS and Android
MIT License
396 stars 178 forks source link

"Object reference not set to an instance of an object" on Initialize #329

Open balivo opened 4 years ago

balivo commented 4 years ago

šŸ› Bug Report

The app crash on startup.

Expected behavior

App startup and push works.

Reproduction steps

Just follow the setup steps and "play" running VS on Windows SO.

Configuration

Version: 3.3.10

Platform:

Additional info:

[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.FirebasePushNotification.FirebasePushNotificationManager.Initialize (Foundation.NSDictionary options, System.Boolean autoRegistration) <0x1016d8600 + 0x0004c> in :0 at MYAPP.Mobile.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00014] in PATHTOMYAPP\MYAPP.Mobile.iOS\AppDelegate.cs:29 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at MYAPP.Mobile.iOS.Application.Main (System.String[] args) [0x00001] in PATHTOMYAPP\MYAPP.Mobile.iOS\Main.cs:12 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 ' The app has been terminated.

robertstefandumitru commented 4 years ago

Hello!

I encountered this problem too.

I tried debugging the application on a iPhone 11 Pro Max connected to a Windows 10 PC. I started it using Xamarin Hot Restart feature (preview) in Visual Studio 16.6.4. All packages are up to date.

JanmarlPaulRodriguez commented 4 years ago

Encountered a similar issue, I placed FirebasePushNotificationManager.Initialize() after LoadApplication(new App(new iOSInitializer())). I simply exchange the sequence of the two where FirebasePushNotificationManager.Initialize() would be called first. This fixed the issue for me.

balivo commented 4 years ago

I remove the Plugin and migrate to Azure Notification Hub...

PJTewkesbury commented 3 years ago

Hi, I am getting this error using Xamarin Forms V4.8.0.1687, Xamarin.Firebase.iOS.CloudMessaging V4.7.1, and the getting started guide code.

[HotReload] (2020-12-14 12:07:02.0): INFO: XAML Hot Reload Connected and Ready.
[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: '  at Plugin.FirebasePushNotification.FirebasePushNotificationManager.Initialize (Foundation.NSDictionary options, System.Boolean autoRegistration) [0x00029] in /Users/runner/runners/2.169.1/work/1/s/Plugin.FirebasePushNotification/FirebasePushNotificationManager.ios.cs:141 
  at Plugin.FirebasePushNotification.FirebasePushNotificationManager.Initialize (Foundation.NSDictionary options, Plugin.FirebasePushNotification.NotificationUserCategory[] notificationUserCategories, System.Boolean autoRegistration) [0x00000] in /Users/runner/runners/2.169.1/work/1/s/Plugin.FirebasePushNotification/FirebasePushNotificationManager.ios.cs:176 
  at BuzzApp.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00123] in D:\INTEC.TS\INTEC.TheBuzzApp\Source\BuzzApp\BuzzApp.iOS\AppDelegate.cs:91 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.6.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.6.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at BuzzApp.iOS.Application.Main (System.String[] args) [0x00001] in D:\INTEC.TS\INTEC.TheBuzzApp\Source\BuzzApp\BuzzApp.iOS\Main.cs:18 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 '
The app has been terminated.

I have tried placing the FirebasePushNotificationManager.Initialize in different places with no change in the error. Looking at line 141 of FirebasePushNotificationManager.ios.cs it would appear that https://github.com/CrossGeeks/FirebasePushNotificationPlugin/blob/cda71416f3f847df1b01708868bc1ef1196e33f6/Plugin.FirebasePushNotification/FirebasePushNotificationManager.ios.cs#L141 is where the error is? So why is Messaging.SharedInstance always = null? Any help would be appreciated

Thanks

QuangKhanDo commented 3 years ago

I have same issue here... Does anyone have a solution for this ?

gyb001 commented 3 years ago

Up! Any solution?

balivo commented 3 years ago

Not yet... I remove plugin and migrate to Azure Notification Hub..

AlleSchonWeg commented 2 years ago

The problem only appears on windows with a physical iPhone. https://github.com/xamarin/GoogleApisForiOSComponents/issues/486 I think it has nothing todo with this plugin.