Unable to get UIPushNotification in xamarin forms-iOS

prapra Member ✭✭
Hello,

I have been integrating push notification using firebase in xamarin. I have created distribution provisioning profile and also generated APNS certificate of distribution environment. I can see all certificates are eligible in visual studio. But still not getting any notification from firebase.

I have rechecked bundle identifiers. Also in case of push notification from ios they ask for Auth-Key but still no luck.

Can anyone suggests something helpful.
Thanks in advance

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Which environment are you testing? Did you make it work in the development mode?

  • DeepakDYDeepakDY INMember ✭✭✭

    Hello @LandLu

    I am development environment and notification comes when app is closed if i start app then send notification from FCM console(Cloud Messaging) the notification not comes.

    This is Firebase initialisation

    FirebasePushNotificationManager.Initialize(launchOptions);

    and the RegisteredForRemoteNotifications method called every time when i debug app

      public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
            {
                FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken, FirebaseTokenType.Sandbox);
            }
    
            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);
            }
    
Sign In or Register to comment.