Skip to content

Loading…

Fix #415: Urgent fix for iOS tutorial #438

Closed
wants to merge 5 commits into from
This page is out of date. Refresh to see the latest.
View
4 DevCenter/Mobile/Tutorials/mobile-services-get-started-ios.md
@@ -16,10 +16,12 @@ A screenshot from the completed app is below:
![][0]
-Completing this guide is a prerequisite for all other Mobile Services tutorials for iOS apps.
+Completing this tutorial requires XCode 4.5 and iOS 5.0 or later versions.
<div chunk="../../Shared/Chunks/create-account-and-mobile-note.md" />
+Completing this tutorial is a prerequisite for all other Mobile Services tutorials for iOS apps.
+
<div class="dev-callout"><strong>Note</strong>
<p>To complete this tutorial, you need a Windows Azure account that has the Windows Azure Mobile Services feature enabled. You can create a free trial account and enable preview features in just a couple of minutes. For details, see <a href="../create-a-windows-azure-account/" target="_blank">Create a Windows Azure account and enable preview features</a>. </p>
</div>
View
31 DevCenter/Mobile/Tutorials/mobile-services-get-started-with-data-ios.md
@@ -26,7 +26,7 @@ This tutorial walks you through these basic steps:
4. [Update the app to use Mobile Services]
5. [Test the app against Mobile Services]
-This tutorial requires the [Mobile Services iOS SDK] and [XCode 4.5][Install Xcode] or a later version.
+This tutorial requires the [Mobile Services iOS SDK] and [XCode 4.5][Install Xcode] and iOS 5.0 or later versions.
## <a name="download-app"></a><h2><span class="short-header">Download the project</span>Download the GetStartedWithData project</h2>
@@ -148,27 +148,27 @@ Now that your mobile service is ready, you can update the app to store items in
This creates a property representation for your mobile services table.
-6. In the Management Portal, click **Mobile Services**, and then click the mobile service you just created.
+5. In the Management Portal, click **Mobile Services**, and then click the mobile service you just created.
-7. Click the **Dashboard** tab and make a note of the **Site URL**, then click **Manage keys** and make a note of the **Application key**.
+6. Click the **Dashboard** tab and make a note of the **Site URL**, then click **Manage keys** and make a note of the **Application key**.
![][8]
You will need these values when accessing the mobile service from your app code.
-8. Back in Xcode, open TodoService.m and locate the following commented line of code:
+7. Back in Xcode, open TodoService.m and locate the following commented line of code:
// Initialize the Mobile Service client with your URL and key.
After this comment, add the following line of code:
- self.client = [MSClient clientWithApplicationURLString:@APPURL withApplicationKey:@"APPKEY"];
+ self.client = [MSClient clientWithApplicationURLString:@"APPURL" withApplicationKey:@"APPKEY"];
This creates an instance of the Mobile Services client.
-9. Replace the values of **APPURL** and **APPKEY** in this code with the URL and application key from the mobile service that you acquired in step 6.
+8. Replace the values of **APPURL** and **APPKEY** in this code with the URL and application key from the mobile service that you acquired in step 6.
-10. Locate the following commented line of code:
+9. Locate the following commented line of code:
// Create an MSTable instance to allow us to work with the TodoItem table.
@@ -178,7 +178,7 @@ Now that your mobile service is ready, you can update the app to store items in
This creates the TodoItem table instance.
-11. Locate the following commented line of code:
+10. Locate the following commented line of code:
// Create a predicate that finds items where complete is false comment in the refreshDataOnSuccess method.
@@ -188,7 +188,7 @@ Now that your mobile service is ready, you can update the app to store items in
This creates a query to return all tasks that have not yet been completed.
-12. Locate the following commented line of code:
+11. Locate the following commented line of code:
// Query the TodoItem table and update the items property with the results from the service.
@@ -201,6 +201,19 @@ Now that your mobile service is ready, you can update the app to store items in
completion();
}];
+12. Locate the **addItem** method, and replace the body of the method with the following code:
+
+ // Insert the item into the TodoItem table and add to the items array on completion
+ [self.table insert:item completion:^(NSDictionary *result, NSError *error) {
+ NSUInteger index = [items count];
+ [(NSMutableArray *)items insertObject:item atIndex:index];
+
+ // Let the caller know that we finished
+ completion(index);
+ }];
+
+ This code sends an insert request to the mobile service.
+
13. Locate the **completeItem** method, and replace the body of the method with the following code:
// Update the item in the TodoItem table and remove from the items array on completion
View
37 DevCenter/Mobile/Tutorials/mobile-services-get-started-with-users-dotnet.md
@@ -21,10 +21,10 @@ This tutorial walks you through these basic steps to enable authentication in yo
This tutorial is based on the Mobile Services quickstart. You must also first complete the tutorial [Get started with Mobile Services].
<div class="dev-callout"><b>Note</b>
- <p>This tutorial demonstrates the basic method provided by Mobile Services to authenticate users by using a variety of identity providers. This method is easy to configure and supports multiple providers. However, this method also requires users to log-in every time your app starts. To instead use Live Connect to provide a single sign-on experience in your Windows Store app, see the topic <a href="/en-us/develop/mobile/tutorials/single-sign-on-win8-dotnet">Single sign-on for Windows Store apps by using Live Connect</a>.</p>
+ <p>This tutorial demonstrates the basic method provided by Mobile Services to authenticate users by using a variety of identity providers. This method is easy to configure and supports multiple providers. However, this method also requires users to log-in every time your app starts. To instead use Live Connect to provide a single sign-on experience in your Windows Store app, see the topic <a href="/en-us/develop/mobile/tutorials/single-sign-on-windows-8-dotnet">Single sign-on for Windows Store apps by using Live Connect</a>.</p>
</div>
-<a name="register"></a><h2><span class="short-header">Register your app</span>Register your app for authentication and configure Mobile Services</h2>
+<h2><span class="short-header">Register your app</span><a name="register"></a>Register your app for authentication and configure Mobile Services</h2>
To be able to authenticate users, you must register your app with an identity provider. You must then register the provider-generated client secret with Mobile Services.
@@ -51,7 +51,7 @@ To be able to authenticate users, you must register your app with an identity pr
Both your mobile service and your app are now configured to work with your chosen authentication provider.
-<a name="permissions"></a><h2><span class="short-header">Restrict permissions</span>Restrict permissions to authenticated users</h2>
+<h2><span class="short-header">Restrict permissions</span><a name="permissions"></a>Restrict permissions to authenticated users</h2>
1. In the Management Portal, click the **Data** tab, and then click the **TodoItem** table.
@@ -69,7 +69,7 @@ Both your mobile service and your app are now configured to work with your chose
Next, you will update the app to authenticate users before requesting resources from the mobile service.
-<a name="add-authentication"></a><h2><span class="short-header">Add authentication</span>Add authentication to the app</h2>
+<h2><span class="short-header">Add authentication</span><a name="add-authentication"></a>Add authentication to the app</h2>
5. Open the project file mainpage.xaml.cs and add the following using statement:
@@ -82,28 +82,23 @@ Next, you will update the app to authenticate users before requesting resources
{
while (user == null)
{
-
- user = await App.MobileService
- .LoginAsync(
- MobileServiceAuthenticationProvider.Facebook);
- if (user.UserId != null)
+ string message;
+ try
{
-
- var message =
+ user = await App.MobileService
+ .LoginAsync(MobileServiceAuthenticationProvider.Facebook);
+ message =
string.Format("You are now logged in - {0}", user.UserId);
- var dialog = new MessageDialog(message);
- dialog.Commands.Add(new UICommand("OK"));
- await dialog.ShowAsync();
}
- else
+ catch (InvalidOperationException)
{
- user = null;
- var dialog =
- new MessageDialog("You must log in.", "Login Required");
- dialog.Commands.Add(new UICommand("OK"));
- await dialog.ShowAsync();
+ message = "You must log in. Login Required";
}
- }
+
+ var dialog = new MessageDialog(message);
+ dialog.Commands.Add(new UICommand("OK"));
+ await dialog.ShowAsync();
+ }
}
This creates a member variable for storing the current user and a method to handle the authentication process. The user is authenticated by using a Facebook login.
View
22 DevCenter/Mobile/Tutorials/mobile-services-get-started-with-users-ios.md
@@ -22,11 +22,13 @@ This tutorial walks you through these basic steps to enable authentication in yo
This tutorial is based on the Mobile Services quickstart. You must also first complete the tutorial [Get started with Mobile Services].
+Completing this tutorial requires XCode 4.5 and iOS 5.0 or later versions.
+
<!--<div class="dev-callout"><b>Note</b>
<p>This tutorial demonstrates the basic method provided by Mobile Services to authenticate users by using a variety of identity providers. This method is easy to configure and supports multiple providers. However, this method also requires users to log-in every time your app starts. To instead use Live Connect to provide a single sign-on experience in your Windows Store app, see the topic <a href="/en-us/develop/mobile/tutorials/single-sign-on-win8-dotnet">Single sign-on for Windows Store apps by using Live Connect</a>.</p>
</div>-->
-<a name="register"></a><h2><span class="short-header">Register your app</span>Register your app for authentication and configure Mobile Services</h2>
+<h2><span class="short-header">Register your app</span><a name="register"></a>Register your app for authentication and configure Mobile Services</h2>
To be able to authenticate users, you must register your app with an identity provider. You must then register the provider-generated client secret with Mobile Services.
@@ -53,7 +55,7 @@ To be able to authenticate users, you must register your app with an identity pr
Both your mobile service and your app are now configured to work with your chosen authentication provider.
-<a name="permissions"></a><h2><span class="short-header">Restrict permissions</span>Restrict permissions to authenticated users</h2>
+<h2><span class="short-header">Restrict permissions</span><a name="permissions"></a>Restrict permissions to authenticated users</h2>
1. In the Management Portal, click the **Data** tab, and then click the **TodoItem** table.
@@ -71,23 +73,15 @@ Both your mobile service and your app are now configured to work with your chose
Next, you will update the app to authenticate users before requesting resources from the mobile service.
-<a name="add-authentication"></a><h2><span class="short-header">Add authentication</span>Add authentication to the app</h2>
-
-5. Open the project file TodoListController.m and in the **@interface TodoListController** declaration block, add the following code:
-
- @property (strong, nonatomic) TodoService *todoService;
-
-6. In the **@interface TodoListController** declaration block, add the following code:
-
- @synthesize todoService;
+<h2><span class="short-header">Add authentication</span><a name="add-authentication"></a>Add authentication to the app</h2>
-7. In the **viewDidLoad** method, remove the following code that reloads the data into the table:
+1. Open the project file TodoListController.m and in the **viewDidLoad** method, remove the following code that reloads the data into the table:
[todoService refreshDataOnSuccess:^{
[self.tableView reloadData];
}];
-7. Just after the **viewDidLoad** method, add the following code:
+2. Just after the **viewDidLoad** method, add the following code:
- (void)viewDidAppear:(BOOL)animated
{
@@ -131,7 +125,7 @@ Next, you will update the app to authenticate users before requesting resources
<p>If you are using an identity provider other than Facebook, change the value passed to <strong>loginViewControllerWithProvider</strong> above to one of the following: <i>microsoftaccount</i>, <i>facebook</i>, <i>twitter</i>, or <i>google</i>.</p>
</div>
-9. Press the **Run** button to build the project, start the app in the iPhone emulator, then log-on with your chosen identity provider.
+3. Press the **Run** button to build the project, start the app in the iPhone emulator, then log-on with your chosen identity provider.
When you are successfully logged-in, the app should run without errors, and you should be able to query Mobile Services and make updates to data.
View
26 DevCenter/Mobile/Tutorials/mobile-services-get-started-with-users-js.md
@@ -21,10 +21,10 @@ This tutorial walks you through these basic steps to enable authentication in yo
This tutorial is based on the Mobile Services quickstart. You must also first complete the tutorial [Get started with Mobile Services].
<div class="dev-callout"><b>Note</b>
- <p>This tutorial demonstrates the basic method provided by Mobile Services to authenticate users by using a variety of identity providers. This method is easy to configure and supports multiple providers. However, this method also requires users to log-in every time your app starts. To instead use Live Connect to provide a single sign-on experience in your Windows Store app, see the topic <a href="/en-us/develop/mobile/tutorials/single-sign-on-win8-js">Single sign-on for Windows Store apps by using Live Connect</a>.</p>
+ <p>This tutorial demonstrates the basic method provided by Mobile Services to authenticate users by using a variety of identity providers. This method is easy to configure and supports multiple providers. However, this method also requires users to log-in every time your app starts. To instead use Live Connect to provide a single sign-on experience in your Windows Store app, see the topic <a href="/en-us/develop/mobile/tutorials/single-sign-on-windows-8-js">Single sign-on for Windows Store apps by using Live Connect</a>.</p>
</div>
-<a name="register"></a><h2><span class="short-header">Register your app</span>Register your app for authentication and configure Mobile Services</h2>
+<h2><span class="short-header">Register your app</span><a name="register"></a>Register your app for authentication and configure Mobile Services</h2>
To be able to authenticate users, you must register your app with an identity provider. You must then register the provider-generated client secret with Mobile Services.
@@ -51,7 +51,7 @@ To be able to authenticate users, you must register your app with an identity pr
Both your mobile service and your app are now configured to work with your chosen authentication provider.
-<a name="permissions"></a><h2><span class="short-header">Restrict permissions</span>Restrict permissions to authenticated users</h2>
+<h2><span class="short-header">Restrict permissions</span><a name="permissions"></a>Restrict permissions to authenticated users</h2>
1. In the Management Portal, click the **Data** tab, and then click the **TodoItem** table.
@@ -69,28 +69,16 @@ Both your mobile service and your app are now configured to work with your chose
Next, you will update the app to authenticate users before requesting resources from the mobile service.
-<a name="add-authentication"></a><h2><span class="short-header">Add authentication</span>Add authentication to the app</h2>
+<h2><span class="short-header">Add authentication</span><a name="add-authentication"></a>Add authentication to the app</h2>
-1. Open the default.html project file and add the following &lt;script&gt; element in the &lt;head&gt; element.
-
- <script src="///LiveSDKHTML/js/wl.js"></script>
-
- This enables Microsoft IntelliSense in the default.html file.
-
-5. Open the project file default.js and add the following comment to the top of the file.
-
- /// <reference path="///LiveSDKHTML/js/wl.js" />
-
- This enables Microsoft IntelliSense in the default.js file.
-
-5. In the **app.OnActivated** method overload, replace the call to the **refreshTodoItems** method with the following code:
+1. Open the project file default.js and in the **app.OnActivated** method overload, replace the call to the **refreshTodoItems** method with the following code:
var userId = null;
// Request authentication from Mobile Services using a Facebook login.
var login = function () {
return new WinJS.Promise(function (complete) {
- client.login("facebook").done(function (results) {;
+ mobileService.login("facebook").done(function (results) {;
userId = results.userId;
refreshTodoItems();
var message = "You are now logged in as: " + userId;
@@ -107,7 +95,7 @@ Next, you will update the app to authenticate users before requesting resources
var authenticate = function () {
login().then(function () {
- if (user === null) {
+ if (userId === null) {
// Authentication failed, try again.
authenticate();
View
2 DevCenter/Mobile/Tutorials/mobile-services-get-started.md
@@ -15,7 +15,7 @@ A screenshot from the completed app is below:
![][0]
-Completing this guide is a prerequisite for all other Mobile Services tutorials for Windows Store apps.
+Completing this tutorial is a prerequisite for all other Mobile Services tutorials for Windows Store apps.
<div chunk="../../Shared/Chunks/create-account-and-mobile-note.md" />
Something went wrong with that request. Please try again.