Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 0bc8046

Browse files
authored
Fix the code to demonstrate how to serialize the device token to send it to backend server. (#401)
1 parent c48c4d6 commit 0bc8046

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Notifications/AppDelegate.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using UIKit;
34
using Foundation;
45
using Example_Notifications.Screens;
@@ -95,7 +96,12 @@ public override void ReceivedRemoteNotification (UIApplication application, NSDi
9596
/// </summary>
9697
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
9798
{
98-
deviceToken = deviceToken.ToString ();
99+
var bytes = deviceToken.ToArray<byte>();
100+
var hexArray = bytes.Select(b => b.ToString("x2")).ToArray();
101+
102+
//This is the token that you need to send to your backend-server to perform the
103+
//device registration/installation on the backend if you want.
104+
var token = string.Join(string.Empty, hexArray);
99105
}
100106

101107
/// <summary>

0 commit comments

Comments
 (0)