FirebasePushNotificationPlugin icon indicating copy to clipboard operation
FirebasePushNotificationPlugin copied to clipboard

CrossFirebasePushNotification.Current.OnNotificationReceived not firing in iOS.

Open nmssalman opened this issue 5 years ago • 5 comments

🐛 Bug Report

Here is how my AppDelegate looks like

`using System; using System.Collections.Generic; using System.Linq;

using Foundation; using Plugin.FirebasePushNotification; using UIKit;

namespace onlinefirebase.iOS { // The UIApplicationDelegate for the application. This class is responsible for launching the // User Interface of the application, as well as listening (and optionally responding) to // application events from iOS. [Register("AppDelegate")] public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate { // // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init();

        LoadApplication(new App());
        FirebasePushNotificationManager.Initialize(options, true);
        return base.FinishedLaunching(app, options);
    }
    public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
    {
        FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
    }

    public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
    {
        FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error);

    }
    // To receive notifications in foregroung on iOS 9 and below.
    // To receive notifications in background in any iOS version
    public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
    {
        // If you are receiving a notification message while your app is in the background,
        // this callback will not be fired 'till the user taps on the notification launching the application.

        // If you disable method swizzling, you'll need to call this method. 
        // This lets FCM track message delivery and analytics, which is performed
        // automatically with method swizzling enabled.
        FirebasePushNotificationManager.DidReceiveMessage(userInfo);
        // Do your magic to handle the notification data
        System.Console.WriteLine(userInfo);

        completionHandler(UIBackgroundFetchResult.NewData);
    }
}

} `

Here is how i receive notification.

`using System; using Plugin.FirebasePushNotification; using Xamarin.Forms; using Xamarin.Forms.Xaml;

namespace onlinefirebase { public partial class App : Application { public App() { InitializeComponent();

        MainPage = new MainPage();


        CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) =>
        {
            System.Diagnostics.Debug.WriteLine($"TOKEN : {p.Token}");
        };

        CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
        {
            System.Diagnostics.Debug.WriteLine("Received");
        };

       
    }

    protected override void OnStart()
    {
    }

    protected override void OnSleep()
    {
    }

    protected override void OnResume()
    {
    }
}

} `

I'm receiving Token successfully, but when i push the data from firebase console, i'm not receiving any data.

Can anyone advice me what's wrong with me iOS C# application? even in a new solution also the same. Version: 1.x

Platform:

  • [x] :iphone: iOS
  • [ ] :robot: Android
  • [ ] :checkered_flag: WPF
  • [ ] :earth_americas: UWP
  • [ ] :apple: MacOS
  • [ ] :tv: tvOS
  • [x] :monkey: Xamarin.Forms

nmssalman avatar Jun 20 '20 06:06 nmssalman

@nmssalman please fix the code formatting on this issue, it is hard to follow it.

almirvuk avatar Jun 30 '20 11:06 almirvuk

@rdelrosario maybe this is the same issue: 321.

almirvuk avatar Jun 30 '20 11:06 almirvuk

@almirvuk Hello~ I have same problem here. I got an message below from console in Xcode.

6.22.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure]; (FirebaseApp.configure() in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.

It is raised when I sent an message in Firebase Console.

daeyeonjoo avatar Jul 06 '20 12:07 daeyeonjoo

@daeyeonjoo same issue, have u resolved?

frungillo avatar Mar 31 '22 07:03 frungillo

Same issue here, has anyone resolved? Thanks.

iOS version: 15.3 XCode: 13.2.1

Dipannita20 avatar Mar 31 '22 11:03 Dipannita20