Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

xamarin forms: InvalidRegistration error in postman when try to send notification to ios device

$
0
0

I am implementing push notifications using FCM in my Xamarin.Forms project. In the iOS project, I am getting the fcmtoken from RegisteredForRemoteNotifications. When I am sending a notification for the token by Postman I am getting InvalidRegistration error. I already worked on the android part and notification is successfully delivered for android device.

AppDelegate.cs

public async override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            if (deviceToken == null)
            {
                return;
            }
            Console.WriteLine($"Token received: {deviceToken}");
            await SendRegistrationTokenToMainPRoject(deviceToken);
        }

        async Task SendRegistrationTokenToMainPRoject(NSData deviceToken)
        {
            MessagingCenter.Send<object, string>(this, "fcmtoken", deviceToken.ToString());
        }

        public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
        {
            Console.WriteLine($"Failed to register for remote notifications: {error.Description}");
        }

Postman Response

{
    "multicast_id": 8754155136812875313,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidRegistration"
        }
    ]
}

Postman Body

 {
    "to" : "d20ad003 7473bfba 85dffc33 1534decf b4b886f1 c738878f fd7f2c60 d9dabc36",
 "collapse_key" : "type_a",
 "data" : {
     "body" : "Body of Your Notification in Data",
     "title": "Title of Your Notification in Title",
     "key_1" : "Value for key_1",
     "key_2" : "Value for key_2"
 },
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification",
     "sound": "default",
     "content_available" : true
 }
}

I am not using any NuGet packages like FirebasePushNotificationPlugin in IOS. I am receiving the devicefcmtoken in log but pushing from postman results InvalidRegistration error.

Found the same thread here, So I installed FirebasePushNotificationPlugin in IOS and capture the devicefcmtoken by the following code, but FirebaseInstanceIdcould not be found error is getting.

var fcmToken = FirebaseInstanceId.Instance.Token;

How can I solve this issue?


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>