<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - Service Bus Notification Hubs - Code Walkthrough - iOS Edition</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Blogs/Subscribe/Service-Bus-Notification-Hubs-Code-Walkthrough-iOS-Edition/RSS"></atom:link>
	<image>
		<url>http://media.ch9.ms/ch9/77cc/cae058ab-452c-4f78-959c-5c2e96ea77cc/notificationhubsios_220.jpg</url>
		<title>Channel 9 - Service Bus Notification Hubs - Code Walkthrough - iOS Edition</title>
		<link></link>
	</image>
	<description>[This is the iOS version of the previously posted Walkthrough. If you&#39;ve already watched the Windows 8 Edition, skip to 10 minutes&amp;nbsp;25 seconds where the actual code walkthrough starts] In this clip I&#39;ll walk you through the basic principles of the brand-new Windows Azure Service Bus Notification Hubs in a somewhat more formal and serious fashion than&amp;nbsp;in my chat with Elio. Recapping from the other post,Service Bus Notification Hubs&amp;nbsp;are an intrinsic feature of Windows Azure Service Bus and are different from other push notification services in&amp;nbsp;four key areas: Complete client registration management. Your backend application (if you even have one) does not need to worry at all about device-ids or channels or other&amp;nbsp;particulars of&amp;nbsp;push notifications and doesn&#39;t need to cooperate in management. It doesn&#39;t even have to be a web app that&#39;s publicly accessible.&amp;nbsp;&amp;nbsp; Platform independence. Service Bus Notification Hubs allow cross-platform push notifications so that iOS Alerts and&amp;nbsp;Windows&amp;nbsp;Live Tiles can be targeted with a single event message.&amp;nbsp; Broadcast and tag-based Multicast - Service Bus Notification Hubs&amp;nbsp;are optimized around automatic notification broadcast to many thousand devices&amp;nbsp;with low latency. One message in, thousands of notifications out. Mass&amp;nbsp;customization&amp;nbsp;- Notification Hub notification templates allow for customization of notification delivery for each individual registration, allowing&amp;nbsp;each instance of a&amp;nbsp;client App to choose how it wants to receive events. In this preview, Notification Hubs are able to push notifications to Windows Store apps and iOS apps from .NET back-ends. Support for Android and Windows Phone, along with additional back-end technologies (including Windows Azure Mobile Services) will be added soon. After the basic intro, I&#39;m showing how to create and provision a&amp;nbsp;iOS application from scratch, how to hook it up to a new Notification Hub, and send it a notification&amp;nbsp;Alert using the portals and Visual Studio Express 2012 Web. (The equivalent&amp;nbsp;Windows 8&amp;nbsp;walkthrough is here) For those of you with a &amp;quot;TL;DW&amp;quot; attention span (too long; didn&#39;t watch), here&#39;s the whole extent of the code added to the stock iOS code template to enable Service Bus Notifications and that includes re-registering existing registrations at App startup.&amp;nbsp;Decoration excluded it&#39;s 6 functional&amp;nbsp;lines including one required by iOS - admittedly, without error handling. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSString * connectionString =
    [SBConnectionString stringWithEndpoint:@&amp;quot;https://myhub-euw-ns.servicebus.windows.net/&amp;quot; listenAccessSecret:@&amp;quot;... secret...&amp;quot;];
    
    self.hub = [[SBNotificationHub alloc] initWithConnectionString: connectionString notificationHubPath:@&amp;quot;myhub&amp;quot;];
    
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
     ...
    return YES;
}


- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
    [self.hub refreshRegistrationsWithDeviceToken:deviceToken completion:
       ^(NSError *error) {
         if ( error == nil )
         {
             [self.hub defaultRegistrationExistsWithCompletion:^(BOOL exists, NSError *error2) {
                 if ( error2 == nil &amp;amp;&amp;amp; !exists )
                 {
                     [self.hub createDefaultRegistrationWithTags:nil completion:
                      
                      ^(NSError *error3) {
                          if ( error3 != nil) {
                          }
                      }];
                 }
             }];
         }
     }];
}
 The event-source code, written on the server-side for a Windows Azure Web Site&amp;nbsp;in ASP.NET,&amp;nbsp;is similarly terse: var cs = ServiceBusConnectionStringBuilder.CreateUsingSharedAccessSecretWithFullAccess( &amp;quot;myhub-euw-ns&amp;quot;, &amp;quot;...secret...&amp;quot;);
var nh = NotificationHubClient.CreateClientFromConnectionString( cs, &amp;quot;myhub&amp;quot;);

nh.SendAppleNativeNotification( AppleNotificationJsonBuilder.Create(TextBox1.Text).ToJsonString()); &amp;nbsp;3 lines. Three lines. No management of device ids. No public endpoint for the phone to talk to. Service Bus does all that. It really is worth playing with.&amp;nbsp; And here are all the key links .... Feature guide (Windows Store Apps) -&amp;nbsp;http://go.microsoft.com/fwlink/?LinkID=275828 Feature guide (iOS) - &amp;nbsp;http://go.microsoft.com/fwlink/?LinkId=275829 Fundamentals -&amp;nbsp;http://go.microsoft.com/fwlink/?LinkId=277072 Tutorial (Windows Store Apps) -&amp;nbsp;http://go.microsoft.com/fwlink/?LinkId=277073 Tutorial (iOS) -&amp;nbsp;http://go.microsoft.com/fwlink/?LinkId=277074 &amp;nbsp;SDKs: Windows 8 Managed Client Library -&amp;nbsp;http://go.microsoft.com/fwlink/?LinkID=277160 iOS Client Library -&amp;nbsp;http://go.microsoft.com/fwlink/?LinkID=277161 Preview client NuGet -&amp;nbsp;http://nuget.org/packages/ServiceBus.Preview </description>
	<link></link>
	<language>en</language>
	<pubDate>Mon, 20 May 2013 16:58:12 GMT</pubDate>
	<lastBuildDate>Mon, 20 May 2013 16:58:12 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: Service Bus Notification Hubs - Code Walkthrough - iOS Edition</title>
		<description>
			<![CDATA[<p>All of you who didn't have a heart attack at 41:21, please raise your hand. (If you're still alive.. )</p><p>posted by BassPassion</p>]]>
		</description>
		<link>http://channel9.msdn.com/Blogs/Subscribe/Service-Bus-Notification-Hubs-Code-Walkthrough-iOS-Edition#c635020882976754669</link>
		<pubDate>Sat, 20 Apr 2013 20:58:17 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Blogs/Subscribe/Service-Bus-Notification-Hubs-Code-Walkthrough-iOS-Edition#c635020882976754669</guid>
		<dc:creator>BassPassion</dc:creator>
	</item>
</channel>
</rss>