Question: I am trying to implement push notifications for MonoTouch but I couldn´t find samples of this anywhere. My problem is trying to read the deviceID into a .NET string. 

The output below is just a lot of question marks so I am doing something wrong here. 

Any help would be greatly appreciated!

```
    public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
    {
        Console.WriteLine("Converting device ID...");
        NSString s = NSString.FromData(deviceToken, NSStringEncoding.UTF8);
        Console.WriteLine("DEVICE ID IS: " + s);
        s = NSString.FromData(deviceToken, NSStringEncoding.ASCIIStringEncoding);
        Console.WriteLine("DEVICE ID IS: " + s);
         s = NSString.FromData(deviceToken, NSStringEncoding.Unicode);
        Console.WriteLine("DEVICE ID IS: " + s);

    }

```

Answer: 
Here's a great article showing how to do push notifications with MonoTouch:

<http://weblogs.thinktecture.com/cweyer/2010/12/implementing-push-notifications-for-ios-with-c-monotouch-using-the-cloud-urban-airship.html>

Here's the snippet that does what you want:

```
var str = (NSString)Runtime.GetNSObject (
                Messaging.intptr_objc_msgSend (deviceToken.Handle, new Selector("description").Handle));

var deviceTokenString = str.ToString ().Replace ("<", "").Replace (">", "").Replace (" ", "");

```
I've managed to implement this, and I used the following code:

```
NSString newDeviceToken = new NSString(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(new MonoTouch.ObjCRuntime.Class("NSString").Handle, new MonoTouch.ObjCRuntime.Selector("stringWithFormat:").Handle, strFormat.Handle, deviceToken.Handle));
string token = newDeviceToken.ToString();

```

This will provide you with a string which reads

```
< 64characterlonghexstring >

```

You can use a Regex to get rid of the spaces and the "<" ">" character as required. 

I found the following project very useful in getting a Monotouch implementation of push notifications working:
[C# Apple Push Notification Service](http://code.google.com/p/apns-sharp/) - it provides client side code as well as server side code.