From 0bc8046ca90cfe91684c85b6bdb12a114e3af793 Mon Sep 17 00:00:00 2001 From: Eder Cardoso Date: Fri, 24 Feb 2023 11:59:52 -0300 Subject: [PATCH] Fix the code to demonstrate how to serialize the device token to send it to backend server. (#401) --- Notifications/AppDelegate.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Notifications/AppDelegate.cs b/Notifications/AppDelegate.cs index 556c7997a..9f91a3488 100644 --- a/Notifications/AppDelegate.cs +++ b/Notifications/AppDelegate.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using UIKit; using Foundation; using Example_Notifications.Screens; @@ -95,7 +96,12 @@ public override void ReceivedRemoteNotification (UIApplication application, NSDi /// public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken) { - deviceToken = deviceToken.ToString (); + var bytes = deviceToken.ToArray(); + var hexArray = bytes.Select(b => b.ToString("x2")).ToArray(); + + //This is the token that you need to send to your backend-server to perform the + //device registration/installation on the backend if you want. + var token = string.Join(string.Empty, hexArray); } ///