<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Lazy Sys Admin&#187; Obj-C</title>
	<atom:link href="http://www.thelazysysadmin.net/tag/obj-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thelazysysadmin.net</link>
	<description>Why do things the hard way?</description>
	<lastBuildDate>Mon, 07 Jun 2010 22:24:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>APNS Send Device Token to Provider</title>
		<link>http://www.thelazysysadmin.net/2009/07/apns-send-device-token-to-provider/</link>
		<comments>http://www.thelazysysadmin.net/2009/07/apns-send-device-token-to-provider/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 05:38:37 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[APNS]]></category>
		<category><![CDATA[Obj-C]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=493</guid>
		<description><![CDATA[I am currently in the middle of designing and developing an application based on the Apple Push Notification Service. There is alot of information about the client side registration and plenty of server side code examples, but I haven&#8217;t found anything that simple demonstrates how to send your device token to the provider service. The [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently in the middle of designing and developing an application based on the Apple Push Notification Service. There is alot of information about the client side registration and plenty of server side code examples, but I haven&#8217;t found anything that simple demonstrates how to send your device token to the provider service.</p>
<p><span id="more-493"></span>The following code is simple (but as a newcomer to Obj-C took me ages to put together). Just press the View Source button on the following panel to see all the code (I am having trouble getting code wrapping to work, so this will be the case until I find a decent syntax highlighter plugin).</p>
<pre class="brush: cpp;">
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

	NSLog(@&quot;devToken=%@&quot;,deviceToken);

	NSString *host = @&quot;yourhost&quot;;
	NSString *URLString = @&quot;/register.php?id=&quot;;
	URLString = [URLString stringByAppendingString:id];
	URLString = [URLString stringByAppendingString:@&quot;&amp;amp;amp;amp;amp;amp;devicetoken=&quot;];

	NSString *dt = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@&quot;&amp;lt;&amp;gt;&quot;]];
	dt = [dt stringByReplacingOccurrencesOfString:@&quot; &quot; withString:@&quot;&quot;];

	URLString = [URLString stringByAppendingString:dt];
	URLString = [URLString stringByAppendingString:@&quot;&amp;amp;amp;amp;amp;amp;devicename=&quot;];
	URLString = [URLString stringByAppendingString:[[UIDevice alloc] name]];

	NSURL *url = [[NSURL alloc] initWithScheme:@&quot;http&quot; host:host path:URLString];
	NSLog(@&quot;FullURL=%@&quot;, url);

	NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

	NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
}
</pre>
<p>If you spot the above code and think &#8220;why the hell has he done it like that&#8221;, it is because I don&#8217;t know any better at the moment. If there is a better way please leave some constructive feedback via the comment form.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/07/apns-send-device-token-to-provider/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
