Skip to content

Commit

Permalink
fixing more fomratting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybostic committed Dec 12, 2013
1 parent a9b00db commit 899dfc6
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 163 deletions.
44 changes: 22 additions & 22 deletions articles/notification-hubs-android-get-started.md
Expand Up @@ -33,7 +33,7 @@ Completing this tutorial is a prerequisite for all other notification hub tutori

1. Navigate to the <a href="http://go.microsoft.com/fwlink/p/?LinkId=268303" target="_blank">Google apis</a> web site, sign-in with your Google account credentials, and then click **Create project...**.

![][1]
![][1]

<div class="dev-callout"><b>Note</b>
<p>When you already have an existing project, you are directed to the <strong>Dashboard</strong> page after login. To create a new project from the Dashboard, expand <strong>API Project</strong>, click <strong>Create...</strong> under <strong>Other projects</strong>, then enter a project name and click <strong>Create project</strong>.</p>
Expand All @@ -47,15 +47,15 @@ Completing this tutorial is a prerequisite for all other notification hub tutori

4. Click **API Access**, and then click **Create new Server key...**

![][2]
![][2]

5. In **Configure Server Key for API Project**, click **Create**.

![][3]
![][3]

6. Make a note of the **API key** value.

![][4]
![][4]

Next, you will use this API key value to enable your notification hub to authenticate with GCM and send push notifications on behalf of your application.

Expand All @@ -65,55 +65,55 @@ Next, you will use this API key value to enable your notification hub to authent

2. Click on **App Services**, then **Service Bus**, then **Notification Hub**, then **Quick Create**.

![][7]
![][7]

3. Type a name for your notification hub, select your desired region, and then click **Create a new Notification Hub**.

![][8]
![][8]

4. Click the namespace you just created (usually ***notification hub name*-ns**), and then click **Configure** at the top.

![][9]
![][9]

5. Click the **Notification Hubs** tab at the top, and then click on the notification hub you just created.

![][10]
![][10]

6. Click the **Configure** tab at the top, enter the **API Key** value you obtained in the previous section, and then click **Save**.

![][11]
![][11]

7. Select the **Dashboard** tab at the top, then click **Connection Information**. Take note of the two connection strings.

![][12]
![][12]

Your notification hub is now configured to work with GCM, and you have the connection strings to register your app and send push notifications.

<h2><a name="connecting-app"></a><span class="short-header">Connecting your app</span>Connecting your app to the Notification Hub</h2>

1. In Eclipse ADT, create a new Android project (File, New, Android Application).

![][13]
![][13]

2. Set Minimum Required SDK to API 8: Android 2.2 (Froyo). Then follow the wizard, making sure to click **Create activity** to create a blank activity.

![][14]
![][14]

3. Open the Android SDK Manager from the top toolbar of Eclipse. Click **Google APIs**, **Google Cloud Messaging for Android Library**, and **Google Play Service**, as shown below. Click Install Packages. Restart Eclipse.

<div class="dev-callout"><b>Note</b>
<p>To complete the procedure in this topic, you must have a Google account that has a verified email address. To create a new Google account, go to <a href="http://go.microsoft.com/fwlink/p/?LinkId=268302" target="_blank">accounts.google.com</a>.</p>
</div>

![][15]
![][15]

4. Browse to the SDK path, and copy the following files to the \libs directory of your project in the Package Explorer: \extras\google\gcm\gcm-client\dist\gcm.jar; \extras\google\google_play_services\libproject\google-play-services_lib\libs\google-play-services.jar.

5. Download the Notification Hubs Android SDK from <a href="https://go.microsoft.com/fwLink/?LinkID=280126&clcid=0x409">here</a>. Extract the .zip file and copy the file notificationhubs\notification-hubs-sdk.jar to the \libs directory of your project in the Package Explorer.

6. Right-click on the project in the Package Explorer, and click **Properties**. Then click **Android** in the left-hand pane. Check the **Google APIs** target. Click **OK**.

![][16]
![][16]

Now, set up the application to obtain a *registrationId* from GCM, and use the *registrationId* to register the app instance to the notification hub.

Expand Down Expand Up @@ -181,7 +181,7 @@ Your notification hub is now configured to work with GCM, and you have the conne

12. Create a new class (right-click your app package in Package Explorer and click **New**, then click **Class**). Name the class **MyBroadcastReceiver**, derived from **android.content.BroadcastReceiver**.

![][17]
![][17]

13. Add the following code to **MyBroadcastReceiver**:

Expand Down Expand Up @@ -232,18 +232,18 @@ When you run this app in the emulator, make sure that you use an Android Virtual

1. From **Window**, click **Android Virtual Device Manager**, select your device, and then click **Edit**.

![][18]
![][18]

2. Select **Google APIs** in **Target**, then click **OK**.

![][19]
![][19]

3. On the top toolbar, click **Run**, and then select your app. This starts the emulator and run the app.

4. The app retrieves the *registrationId* from GCM and registers with the Notification Hub.

<div class="dev-callout"><b>Note</b>
<p>In order to receive push notifications, you must set up a Google account on your Android Virtual Device (in the emulator, navigate to **Settings** and click **Add Account**). Also, make sure that the emulator is connected to the Internet.</p>
<p>In order to receive push notifications, you must set up a Google account on your Android Virtual Device (in the emulator, navigate to <strong>Settings</strong> and click <strong>Add Account</strong>). Also, make sure that the emulator is connected to the Internet.</p>
</div>

<h2><a name="send"></a><span class="short-header">Send notification</span>Send notification from your back-end</h2>
Expand All @@ -254,7 +254,7 @@ To send notifications using a .NET app:

1. Create a new Visual C# console application:

![][20]
![][20]

2. Add a reference to the Windows Azure Service Bus SDK with the <a href="http://nuget.org/packages/WindowsAzure.ServiceBus/">WindowsAzure.ServiceBus NuGet package</a>. In the Visual Studio main menu, click **Tools**, then **Library Package Manager**, then **Package Manager Console**. Then, in the console window type:

Expand All @@ -281,19 +281,19 @@ To send notifications using a .NET app:

5. Press the F5 key to run the app. You should receive a toast notification.

![][21]
![][21]

To send a notification using a Mobile Service, follow [Get started with Mobile Services], then:

1. Log on to the [Windows Azure Management Portal], and select your Mobile Service.

2. Select the tab **Scheduler** on the top.

![][22]
![][22]

3. Create a new scheduled job, insert a name, and select **On demand**.

![][23]
![][23]

4. When the job is created, click the job name. Then click the tab **Script** in the top bar.

Expand Down
4 changes: 2 additions & 2 deletions articles/notification-hubs-aspnet-notify-users.md
Expand Up @@ -133,9 +133,9 @@ The next step is to add the registration logic for notification hubs to the ASP.

4. In the left pane, select the **Online** category, search for `WindowsAzure.ServiceBus`, click **Install** on the **Windows Azure Service Bus** package, then accept the license agreement.

![][2]
![][2]

This adds the Microsoft.ServiceBus.dll assembly to your project.
This adds the Microsoft.ServiceBus.dll assembly to your project.

5. In Solution Explorer, right-click the **Controllers** folder, click **Add**, click **Controller...**, then type `RegisterController` for **Controller name**, choose **Empty API controller**, and click **Add**.

Expand Down
Expand Up @@ -2,7 +2,7 @@
# Register the current user for push notifications by using ASP.NET

<div class="dev-center-tutorial-selector sublanding">
<a href="/en-us/manage/services/notification-hubs/register-users-with-aspnet-dotnet" title="Windows Store C#">Windows Store C#</a><a href="/en-us/manage/services/notification-hubs/register-users-with-aspnet-ios" title="iOS" class="current">iOS</a>
<a href="/en-us/documentation/articles/notification-hubs-windows-store-aspnet-register-user-push-notifications/" title="Windows Store C#">Windows Store C#</a><a href="/en-us/documentation/articles/notification-hubs-ios-aspnet-register-user-push-notifications/" title="iOS" class="current">iOS</a>
</div>

This topic shows you how to request push notification registration with Windows Azure Notification Hubs when registration is performed by ASP.NET Web API. This topic extends the tutorial [Notify users with Notification Hubs]. You must have already completed the required steps in that tutorial to create the authenticated mobile service. For more information on the notify users scenario, see [Notify users with Notification Hubs].
Expand All @@ -19,24 +19,24 @@ This topic shows you how to request push notification registration with Windows

At this point, your storyboard looks like the following:

![][0]
![][0]

2. In the assistant editor, create outlets for all the switched controls and call them, connect the text fields with the View Controller (delegate), and create an **Action** for the **login** button.

![][1]
![][1]

Your BreakingNewsViewController.h file should now contain the following code:
Your BreakingNewsViewController.h file should now contain the following code:
@property (weak, nonatomic) IBOutlet UILabel *installationId;
@property (weak, nonatomic) IBOutlet UITextField *User;
@property (weak, nonatomic) IBOutlet UITextField *Password;
- (IBAction)login:(id)sender;
@property (weak, nonatomic) IBOutlet UILabel *installationId;
@property (weak, nonatomic) IBOutlet UITextField *User;
@property (weak, nonatomic) IBOutlet UITextField *Password;
- (IBAction)login:(id)sender;

5. Create a class named **DeviceInfo**, and copy the following code into the interface section of the file DeviceInfo.h:

@property (readonly, nonatomic) NSString* installationId;
@property (nonatomic) NSData* deviceToken;
@property (readonly, nonatomic) NSString* installationId;
@property (nonatomic) NSData* deviceToken;

6. Copy the following code in the implementation section of the DeviceInfo.m file:

Expand Down Expand Up @@ -72,19 +72,19 @@ This topic shows you how to request push notification registration with Windows

7. In PushToUserAppDelegate.h, add the following property singleton:

@property (strong, nonatomic) DeviceInfo* deviceInfo;
@property (strong, nonatomic) DeviceInfo* deviceInfo;

8. In the **didFinishLaunchingWithOptions** method in PushToUserAppDelegate.m, add the following code:

self.deviceInfo = [[DeviceInfo alloc] init];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
self.deviceInfo = [[DeviceInfo alloc] init];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];

The first line initializes the **DeviceInfo** singleton. The second line starts the registration for push notifications, which is already present is you have already completed the [Get Started with Notification Hubs] tutorial.

9. In PushToUserAppDelegate.m, implement the method **didRegisterForRemoteNotificationsWithDeviceToken** in your AppDelegate and add the following code:

self.deviceInfo.deviceToken = deviceToken;
self.deviceInfo.deviceToken = deviceToken;

This sets the device token for the request.

Expand All @@ -94,34 +94,34 @@ This topic shows you how to request push notification registration with Windows

10. In the PushToUserAppDelegate.m file, add the following handler method:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"%@", userInfo);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Notification" message:
[userInfo objectForKey:@"inAppMessage"] delegate:nil cancelButtonTitle:
@"OK" otherButtonTitles:nil, nil];
[alert show];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"%@", userInfo);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Notification" message:
[userInfo objectForKey:@"inAppMessage"] delegate:nil cancelButtonTitle:
@"OK" otherButtonTitles:nil, nil];
[alert show];
}

This method displays an alert in the UI when your app receives notifications while it is running.

9. Open the PushToUserViewController.m file, and return the keyboard in the following implementation:

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.User || theTextField == self.Password) {
[theTextField resignFirstResponder];
}
return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.User || theTextField == self.Password) {
[theTextField resignFirstResponder];
}
return YES;
}

9. In the **viewDidLoad** method in the PushToUserViewController.m file, initialize the installationId label as follows:

DeviceInfo* deviceInfo = [(PushToUserAppDelegate*)[[UIApplication sharedApplication]delegate] deviceInfo];
Self.installationId.text = deviceInfo.installationId;
DeviceInfo* deviceInfo = [(PushToUserAppDelegate*)[[UIApplication sharedApplication]delegate] deviceInfo];
Self.installationId.text = deviceInfo.installationId;
10. Add the following properties in interface in PushToUserViewController.m:

@property (readonly) NSOperationQueue* downloadQueue;
- (NSString*)base64forData:(NSData*)theData;
@property (readonly) NSOperationQueue* downloadQueue;
- (NSString*)base64forData:(NSData*)theData;

11. Then, add the following implementation:

Expand Down

0 comments on commit 899dfc6

Please sign in to comment.