Skip to content

Commit 9caa5fb

Browse files
committed
minor fixes
1 parent 5eaf1b7 commit 9caa5fb

6 files changed

+201
-187
lines changed

articles/app-service-mobile/app-service-mobile-ios-how-to-use-client-library.md

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,11 @@ To register templates, pass templates with your **client.push registerDeviceToke
499499
**Swift**:
500500
501501
```swift
502-
client.push?.registerDeviceToken(NSData(), template: iOSTemplate, completion: { (error) in
503-
if let err = error {
504-
print("ERROR ", err)
505-
}
506-
})
502+
client.push?.registerDeviceToken(NSData(), template: iOSTemplate, completion: { (error) in
503+
if let err = error {
504+
print("ERROR ", err)
505+
}
506+
})
507507
```
508508

509509
Your templates are of type NSDictionary and can contain multiple templates in the following format:
@@ -580,6 +580,7 @@ and allows for additional customization.
580580
and the Pod:
581581

582582
pod 'ADALiOS'
583+
583584
3. Using the Terminal, run `pod install` from the directory containing your project, and then open the generated
584585
Xcode workspace (not the project).
585586
4. Add the following code to your application, according to the language you are using. In each, make these
@@ -671,75 +672,77 @@ provides a more native UX feel and allows for additional customization.
671672
3. Facebook's documentation includes some Objective-C code in the App Delegate. If you are using **Swift**, you
672673
can use the following translations for AppDelegate.swift:
673674

674-
// Add the following import to your bridging header:
675-
// #import <FBSDKCoreKit/FBSDKCoreKit.h>
675+
```swift
676+
// Add the following import to your bridging header:
677+
// #import <FBSDKCoreKit/FBSDKCoreKit.h>
676678

677-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
678-
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
679-
// Add any custom logic here.
680-
return true
681-
}
679+
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
680+
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
681+
// Add any custom logic here.
682+
return true
683+
}
682684

683-
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
684-
let handled = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
685-
// Add any custom logic here.
686-
return handled
687-
}
685+
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
686+
let handled = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
687+
// Add any custom logic here.
688+
return handled
689+
}
690+
```
688691
4. In addition to adding `FBSDKCoreKit.framework` to your project, also add a reference to `FBSDKLoginKit.framework`
689692
in the same way.
690693
5. Add the following code to your application, according to the language you are using.
691694

692-
**Objective-C**:
695+
**Objective-C**:
693696

694-
```objc
695-
#import <FBSDKLoginKit/FBSDKLoginKit.h>
696-
#import <FBSDKCoreKit/FBSDKAccessToken.h>
697-
// ...
698-
- (void) authenticate:(UIViewController*) parent
699-
completion:(void (^) (MSUser*, NSError*)) completionBlock;
700-
{
701-
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
702-
[loginManager
703-
logInWithReadPermissions: @[@"public_profile"]
704-
fromViewController:parent
705-
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
706-
if (error) {
707-
completionBlock(nil, error);
708-
} else if (result.isCancelled) {
709-
completionBlock(nil, error);
710-
} else {
711-
NSDictionary *payload = @{
712-
@"access_token":result.token.tokenString
713-
};
714-
[client loginWithProvider:@"facebook" token:payload completion:completionBlock];
715-
}
716-
}];
717-
}
718-
```
697+
```objc
698+
#import <FBSDKLoginKit/FBSDKLoginKit.h>
699+
#import <FBSDKCoreKit/FBSDKAccessToken.h>
700+
// ...
701+
- (void) authenticate:(UIViewController*) parent
702+
completion:(void (^) (MSUser*, NSError*)) completionBlock;
703+
{
704+
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
705+
[loginManager
706+
logInWithReadPermissions: @[@"public_profile"]
707+
fromViewController:parent
708+
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
709+
if (error) {
710+
completionBlock(nil, error);
711+
} else if (result.isCancelled) {
712+
completionBlock(nil, error);
713+
} else {
714+
NSDictionary *payload = @{
715+
@"access_token":result.token.tokenString
716+
};
717+
[client loginWithProvider:@"facebook" token:payload completion:completionBlock];
718+
}
719+
}];
720+
}
721+
```
719722

720-
**Swift**:
723+
**Swift**:
721724

722-
```swift
723-
// Add the following imports to your bridging header:
724-
// #import <FBSDKLoginKit/FBSDKLoginKit.h>
725-
// #import <FBSDKCoreKit/FBSDKAccessToken.h>
725+
```swift
726+
// Add the following imports to your bridging header:
727+
// #import <FBSDKLoginKit/FBSDKLoginKit.h>
728+
// #import <FBSDKCoreKit/FBSDKAccessToken.h>
726729

727-
func authenticate(parent: UIViewController, completion: (MSUser?, NSError?) -> Void) {
728-
let loginManager = FBSDKLoginManager()
729-
loginManager.logInWithReadPermissions(["public_profile"], fromViewController: parent) { (result, error) in
730-
if (error != nil) {
731-
completion(nil, error)
732-
}
733-
else if result.isCancelled {
734-
completion(nil, error)
735-
}
736-
else {
737-
let payload: [String: String] = ["access_token": result.token.tokenString]
738-
client.loginWithProvider("facebook", token: payload, completion: completion)
730+
func authenticate(parent: UIViewController, completion: (MSUser?, NSError?) -> Void) {
731+
let loginManager = FBSDKLoginManager()
732+
loginManager.logInWithReadPermissions(["public_profile"], fromViewController: parent) { (result, error) in
733+
if (error != nil) {
734+
completion(nil, error)
735+
}
736+
else if result.isCancelled {
737+
completion(nil, error)
738+
}
739+
else {
740+
let payload: [String: String] = ["access_token": result.token.tokenString]
741+
client.loginWithProvider("facebook", token: payload, completion: completion)
742+
}
739743
}
740744
}
741-
}
742-
```
745+
```
743746

744747
## <a name="twitter-fabric"></a>How to: Authenticate users with Twitter Fabric for iOS
745748

articles/app-service-mobile/app-service-mobile-node-backend-how-to-use-server-sdk.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ Back in the **Get started** pane, under **Create a table API**, choose **Node.js
155155
Select the box for **I acknowledge that this will overwrite all site contents**, and then select
156156
**Create TodoItem table**.
157157

158-
### <a name="download-quickstart"></a>Download the Node.js back-end quickstart code project by using Gi
158+
### <a name="download-quickstart"></a>Download the Node.js back-end quickstart code project by using Git
159159

160160
When you create a Node.js Mobile Apps back end by using the portal's **Quick start** pane, a Node.js project
161161
is created for you and deployed to your site. In the portal, you can add tables and APIs, and edit code files for the Node.js
162162
back end. You can also use various deployment tools to download the back-end project so that you
163163
can add or modify tables and APIs, and then republish the project. For more information, see the
164-
[Azure App Service deployment guide].
164+
[Azure App Service deployment guide].
165165
166166
The following procedure uses a Git repository to download the quickstart
167167
project code:
@@ -207,7 +207,9 @@ two facets. Sometimes, however, you might want to only implement a mobile interf
207207
home page to ensure that the app service is up and running. You can either provide your own home page or enable
208208
a temporary home page. To enable a temporary home page, use the following code to instantiate Mobile Apps:
209209
210-
var mobile = azureMobileApps({ homePage: true });
210+
```javascript
211+
var mobile = azureMobileApps({ homePage: true });
212+
```
211213
212214
If you only want this option available when developing locally, you can add this setting to your azureMobile.js
213215
file.

includes/app-service-mobile-android-configure-push-for-firebase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ ms.topic: "include"
44
1. In the [Azure portal](https://portal.azure.com/), click **Browse All** > **App Services**, and then click your Mobile Apps back end. Under **Settings**, click **App Service Push**, and then click your notification hub name.
55
2. Go to **Google (GCM)**, enter the **Server Key** value that you obtained from Firebase in the previous procedure, and then click **Save**.
66

7-
![Set the GCM API key in the portal](./media/app-service-mobile-android-configure-push/mobile-push-api-key.png)
7+
![Set the API key in the portal](./media/app-service-mobile-android-configure-push/mobile-push-api-key.png)
88

99
The Mobile Apps back end is now configured to use Firebase Cloud Messaging. This enables you to send push notifications to your app running on an Android device, by using the notification hub.
Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,103 @@
11
---
22
ms.topic: "include"
33
---
4-
* **.NET backend (C#)**:
4+
**.NET backend (C#)**:
55

6-
1. In Visual Studio, right-click the server project and click **Manage NuGet Packages**, search for `Microsoft.Azure.NotificationHubs`, then click **Install**. This installs the Notification Hubs library for sending notifications from your backend.
7-
2. In the backend's Visual Studio project, open **Controllers** > **TodoItemController.cs**. At the top of the file, add the following `using` statement:
6+
1. In Visual Studio, right-click the server project and click **Manage NuGet Packages**, search for `Microsoft.Azure.NotificationHubs`, then click **Install**. This installs the Notification Hubs library for sending notifications from your backend.
7+
2. In the backend's Visual Studio project, open **Controllers** > **TodoItemController.cs**. At the top of the file, add the following `using` statement:
88

99
```csharp
10-
using Microsoft.Azure.Mobile.Server.Config;
11-
using Microsoft.Azure.NotificationHubs;
10+
using Microsoft.Azure.Mobile.Server.Config;
11+
using Microsoft.Azure.NotificationHubs;
1212
```
1313

14-
3. Replace the `PostTodoItem` method with the following code:
14+
3. Replace the `PostTodoItem` method with the following code:
1515

1616
```csharp
17-
public async Task<IHttpActionResult> PostTodoItem(TodoItem item)
17+
public async Task<IHttpActionResult> PostTodoItem(TodoItem item)
18+
{
19+
TodoItem current = await InsertAsync(item);
20+
// Get the settings for the server project.
21+
HttpConfiguration config = this.Configuration;
22+
23+
MobileAppSettingsDictionary settings =
24+
this.Configuration.GetMobileAppSettingsProvider().GetMobileAppSettings();
25+
26+
// Get the Notification Hubs credentials for the Mobile App.
27+
string notificationHubName = settings.NotificationHubName;
28+
string notificationHubConnection = settings
29+
.Connections[MobileAppSettingsKeys.NotificationHubConnectionString].ConnectionString;
30+
31+
// Create a new Notification Hub client.
32+
NotificationHubClient hub = NotificationHubClient
33+
.CreateClientFromConnectionString(notificationHubConnection, notificationHubName);
34+
35+
// iOS payload
36+
var appleNotificationPayload = "{\"aps\":{\"alert\":\"" + item.Text + "\"}}";
37+
38+
try
1839
{
19-
TodoItem current = await InsertAsync(item);
20-
// Get the settings for the server project.
21-
HttpConfiguration config = this.Configuration;
22-
23-
MobileAppSettingsDictionary settings =
24-
this.Configuration.GetMobileAppSettingsProvider().GetMobileAppSettings();
25-
26-
// Get the Notification Hubs credentials for the Mobile App.
27-
string notificationHubName = settings.NotificationHubName;
28-
string notificationHubConnection = settings
29-
.Connections[MobileAppSettingsKeys.NotificationHubConnectionString].ConnectionString;
30-
31-
// Create a new Notification Hub client.
32-
NotificationHubClient hub = NotificationHubClient
33-
.CreateClientFromConnectionString(notificationHubConnection, notificationHubName);
34-
35-
// iOS payload
36-
var appleNotificationPayload = "{\"aps\":{\"alert\":\"" + item.Text + "\"}}";
37-
38-
try
39-
{
40-
// Send the push notification and log the results.
41-
var result = await hub.SendAppleNativeNotificationAsync(appleNotificationPayload);
42-
43-
// Write the success result to the logs.
44-
config.Services.GetTraceWriter().Info(result.State.ToString());
45-
}
46-
catch (System.Exception ex)
47-
{
48-
// Write the failure result to the logs.
49-
config.Services.GetTraceWriter()
50-
.Error(ex.Message, null, "Push.SendAsync Error");
51-
}
52-
return CreatedAtRoute("Tables", new { id = current.Id }, current);
40+
// Send the push notification and log the results.
41+
var result = await hub.SendAppleNativeNotificationAsync(appleNotificationPayload);
42+
43+
// Write the success result to the logs.
44+
config.Services.GetTraceWriter().Info(result.State.ToString());
45+
}
46+
catch (System.Exception ex)
47+
{
48+
// Write the failure result to the logs.
49+
config.Services.GetTraceWriter()
50+
.Error(ex.Message, null, "Push.SendAsync Error");
5351
}
52+
return CreatedAtRoute("Tables", new { id = current.Id }, current);
53+
}
5454
```
5555

56-
4. Republish the server project.
56+
4. Republish the server project.
57+
58+
**Node.js backend**:
59+
60+
1. If you haven't already done so, [download the quickstart project](../articles/app-service-mobile/app-service-mobile-node-backend-how-to-use-server-sdk.md#download-quickstart) or else use the [online editor in the Azure portal](../articles/app-service-mobile/app-service-mobile-node-backend-how-to-use-server-sdk.md#online-editor).
61+
62+
2. Replace the todoitem.js table script with the following code:
63+
64+
```javascript
65+
var azureMobileApps = require('azure-mobile-apps'),
66+
promises = require('azure-mobile-apps/src/utilities/promises'),
67+
logger = require('azure-mobile-apps/src/logger');
68+
69+
var table = azureMobileApps.table();
70+
71+
// When adding record, send a push notification via APNS
72+
table.insert(function (context) {
73+
// For details of the Notification Hubs JavaScript SDK,
74+
// see http://aka.ms/nodejshubs
75+
logger.info('Running TodoItem.insert');
76+
77+
// Create a payload that contains the new item Text.
78+
var payload = "{\"aps\":{\"alert\":\"" + context.item.text + "\"}}";
79+
80+
// Execute the insert; Push as a post-execute action when results are returned as a Promise.
81+
return context.execute()
82+
.then(function (results) {
83+
// Only do the push if configured
84+
if (context.push) {
85+
context.push.apns.send(null, payload, function (error) {
86+
if (error) {
87+
logger.error('Error while sending push notification: ', error);
88+
} else {
89+
logger.info('Push notification sent successfully!');
90+
}
91+
});
92+
}
93+
return results;
94+
})
95+
.catch(function (error) {
96+
logger.error('Error while running context.execute: ', error);
97+
});
98+
});
99+
100+
module.exports = table;
101+
```
57102

58-
* **Node.js backend**:
59-
60-
1. If you haven't already done so, [download the quickstart project](../articles/app-service-mobile/app-service-mobile-node-backend-how-to-use-server-sdk.md#download-quickstart) or else use the [online editor in the Azure portal](../articles/app-service-mobile/app-service-mobile-node-backend-how-to-use-server-sdk.md#online-editor).
61-
62-
2. Replace the todoitem.js table script with the following code:
63-
64-
```javascript
65-
var azureMobileApps = require('azure-mobile-apps'),
66-
promises = require('azure-mobile-apps/src/utilities/promises'),
67-
logger = require('azure-mobile-apps/src/logger');
68-
69-
var table = azureMobileApps.table();
70-
71-
// When adding record, send a push notification via APNS
72-
table.insert(function (context) {
73-
// For details of the Notification Hubs JavaScript SDK,
74-
// see http://aka.ms/nodejshubs
75-
logger.info('Running TodoItem.insert');
76-
77-
// Create a payload that contains the new item Text.
78-
var payload = "{\"aps\":{\"alert\":\"" + context.item.text + "\"}}";
79-
80-
// Execute the insert; Push as a post-execute action when results are returned as a Promise.
81-
return context.execute()
82-
.then(function (results) {
83-
// Only do the push if configured
84-
if (context.push) {
85-
context.push.apns.send(null, payload, function (error) {
86-
if (error) {
87-
logger.error('Error while sending push notification: ', error);
88-
} else {
89-
logger.info('Push notification sent successfully!');
90-
}
91-
});
92-
}
93-
return results;
94-
})
95-
.catch(function (error) {
96-
logger.error('Error while running context.execute: ', error);
97-
});
98-
});
99-
100-
module.exports = table;
101-
```
102-
103-
2. When editing the file on your local computer, republish the server project.
103+
3. When editing the file on your local computer, republish the server project.

includes/app-service-mobile-windows-universal-test-push.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ ms.topic: "include"
77
2. Stop the Windows Store app and repeat the previous step for the Windows Phone Store app.
88

99
At this point, both devices are registered to receive push notifications.
10+
1011
3. Run the Windows Store app again, and type text in **Insert a TodoItem**, and then click **Save**.
1112

12-
Note that after the insert completes, both the Windows Store and the Windows Phone apps receive a push notification from WNS. The notification is displayed on Windows Phone even when the app isn't running.
13+
Note that after the insert completes, both the Windows Store and the Windows Phone apps receive a push notification from WNS. The notification is displayed on Windows Phone even when the app isn't running.
1314

14-
![](./media/app-service-mobile-windows-universal-test-push/mobile-quickstart-push5-wp8.png)
15+
![](./media/app-service-mobile-windows-universal-test-push/mobile-quickstart-push5-wp8.png)

0 commit comments

Comments
 (0)