Key Features* Write native cross-platform applications with Xamarin * Design user interfaces that can be shared across Android, iOS, and Windows Phone using Xamarin.Forms * Practical cross-platform development strategies Book DescriptionXamarin is a leading cross-platform application development tool used by top companies such as Coca-Cola, Honeywell, and Alaska Airlines to build apps. Version 4 features significant updates to the platform including the release of Xamarin.Forms 2.0 and improvements have been made to the iOS and Android designers. Xamarin was acquired by Microsoft so it is now a part of the Visual Studio family. This book will show you how to build applications for iOS, Android, and Windows. You will be walked through the process of creating an application that comes complete with a back-end web service and native features such as GPS location, camera, push notifications, and other core features. Additionally, you’ll learn how to use external libraries with Xamarin and Xamarin.Forms to create user interfaces. This book also provides instructions for Visual Studio and Windows. This edition has been updated with new screenshots and detailed steps to provide you with a holistic overview of the new features in Xamarin 4. What you will learn* Apple’s MVC design pattern * The Android activity lifecycle * Share C# code across platforms and call native Objective-C or Java libraries from C# * Create a real web service back end in Windows Azure using SQL Azure as database storage * Set up third-party libraries such as NuGet and Objective Sharpie in many different ways, and port a desktop .NET library to Xamarin * Use Xamarin.Mobile for camera, contacts, and location About the Author**Jonathan Peppers** is a Xamarin MVP and lead developer on popular apps and games at Hitcents such as the Hanx Writer (for Tom Hanks) and the Draw a Stickman franchise. Jon has been working with C# for over 10 years working on a wide range of projects at Hitcents. Jon began his career working Self-Checkout software written in WinForms and later migrated to WPF. Over his career, he has worked with many .NET-centric technologies such as ASP.Net WebForms, MVC, Windows Azure, WinRT/UWP, F#, and Unity3D. In recent years, Hitcents has been heavily investing in mobile development with Xamarin, and has development over 50 mobile applications across multiple platforms. Table of Contents1. Xamarin Setup 2. Hello, Platforms! 3. Code Sharing Between iOS and Android 4. XamSnap - A Cross-Platform App 5. XamSnap for iOS 6. XamSnap for Android 7. Deploying and Testing on Devices 8. Contacts, Camera, and Location 9. Web Services with Push Notifications 10. Third-Party Libraries 11. Xamarin.Forms 12. App Store Submission Cover 1 Copyright 3 Credits 4 About the Author 5 About the Reviewer 6 www.PacktPub.com 7 Customer Feedback 8 Table of Contents 9 Preface 13 Chapter 1: Xamarin Setup 19 Understanding Xamarin 20 Installing Xcode 22 Installing Xamarin on Mac OS X 23 Setting up the Android emulator 24 Installing Xamarin on Windows 26 Connecting Visual Studio to a Mac for iOS development 28 Enrolling in the iOS developer program 29 Registering as a Google Play developer 31 Summary 34 Chapter 2: Hello, Platforms! 35 Building your first iOS application 36 Understanding Apple's MVC pattern 40 Using the iOS designer 41 Building your first Android application 47 Understanding Android activities 50 Xamarin's Android designer 54 Summary 58 Chapter 3: Code Sharing Between iOS and Android 59 Learning the MVVM design pattern 60 Comparing project organization strategies 63 Setting up a shared project 65 Working with portable class libraries 67 Using preprocessor statements 68 Simplifying dependency injection 70 Implementing Inversion of Control 72 Summary 75 Chapter 4: XamSnap - A Cross-Platform App 76 Starting our sample application concept 76 Developing our model layer 77 Writing a mock web service 79 Writing the ViewModel layer 85 Implementing our LoginViewModel class 86 Implementing our RegisterViewModel class 87 Implementing our FriendViewModel class 88 Implementing our MessageViewModel class 90 Writing unit tests 93 Setting up a new project for unit tests 93 Writing assertions 94 Summary 99 Chapter 5: XamSnap for iOS 100 Understanding the basics of an iOS app 100 Xamarin.iOS Build Options 103 Using UINavigationController 105 Implementing the login screen 106 Using segues for navigation 112 Setting up UITableView 114 Adding a friends list screen 117 Adding a list of messages 121 Composing messages 125 Summary 128 Chapter 6: XamSnap for Android 129 Introducing the Android Manifest 129 Setting up Material Design 133 Adding a login screen 136 Using ListView and BaseAdapter 140 Implementing the friends list 144 Composing messages 149 Summary 157 Chapter 7: Deploying and Testing on Devices 158 iOS provisioning 159 Android device settings 164 Understanding the linker 166 Understanding AOT compilation 168 Avoiding common memory pitfalls 170 Summary 174 Chapter 8: Contacts, Camera, and Location 175 Introducing Xamarin.Mobile 175 Accessing contacts 177 Retrieving contacts on Android 180 Looking up GPS location 182 Implementing GPS location on Android 186 Accessing the photo library and camera 187 Accessing photos on Android 191 Summary 196 Chapter 9: Web Services with Push Notifications 197 Learning Windows Azure 198 Setting up your Azure account 199 Exploring Azure Functions 201 Creating and calling Azure Functions 202 Using HttpClient in C# 206 Adding more Azure Functions 209 Using the Apple Push Notification service 215 Setting up your provision profile 216 Setting up a certificate for push notifications 217 Making client-side changes for push notifications 219 Sending push notifications from the server-side 222 Implementing Google Cloud Messaging 223 Summary 229 Chapter 10: Third-Party Libraries 230 The Xamarin Component Store 230 Porting existing C# libraries 232 Objective-C bindings 234 Java bindings 238 Using XPath in Java bindings 239 Summary 244 Chapter 11: Xamarin.Forms 245 Creating Hello World in Xamarin.Forms 245 Understanding the architecture behind Xamarin.Forms 248 Using XAML in Xamarin.Forms 250 Using data-binding and MVVM 253 Summary 259 Chapter 12: App Store Submission 260 Following the iOS App Store Review Guidelines 260 Submitting an app to the iOS App Store 264 Creating a distribution provisioning profile 265 Adding your app to iTunes Connect 266 Making an iOS binary for the App Store 267 Signing your Android applications 270 Submitting the app to Google Play 272 Google Play developer program policies 273 Tips for building a successful mobile app 275 Summary 276 Index 277 Key Features * Write native cross-platform applications with Xamarin * Design user interfaces that can be shared across Android, iOS, and Windows Phone using Xamarin.Forms * Practical cross-platform development strategies Book Description Xamarin is a leading cross-platform application development tool used by top companies such as Coca-Cola, Honeywell, and Alaska Airlines to build apps. Version 4 features significant updates to the platform including the release of Xamarin.Forms 2.0 and improvements have been made to the iOS and Android designers. Xamarin was acquired by Microsoft so it is now a part of the Visual Studio family. This book will show you how to build applications for iOS, Android, and Windows. You will be walked through the process of creating an application that comes complete with a back-end web service and native features such as GPS location, camera, push notifications, and other core features. Additionally, you’ll learn how to use external libraries with Xamarin and Xamarin.Forms to create user interfaces. This book also provides instructions for Visual Studio and Windows. This edition has been updated with new screenshots and detailed steps to provide you with a holistic overview of the new features in Xamarin 4. What you will learn * Apple’s MVC design pattern * The Android activity lifecycle * Share C# code across platforms and call native Objective-C or Java libraries from C# * Create a real web service back end in Windows Azure using SQL Azure as database storage * Set up third-party libraries such as NuGet and Objective Sharpie in many different ways, and port a desktop .NET library to Xamarin * Use Xamarin.Mobile for camera, contacts, and location About the Author Jonathan Peppers is a Xamarin MVP and lead developer on popular apps and games at Hitcents such as the Hanx Writer (for Tom Hanks) and the Draw a Stickman franchise. Jon has been working with C# for over 10 years working on a wide range of projects at Hitcents. Jon began his career working Self-Checkout software written in WinForms and later migrated to WPF. Over his career, he has worked with many .NET-centric technologies such as ASP.Net WebForms, MVC, Windows Azure, WinRT/UWP, F#, and Unity3D. In recent years, Hitcents has been heavily investing in mobile development with Xamarin, and has development over 50 mobile applications across multiple platforms. Annotation Develop powerful cross-platform applications with XamarinAbout This Book Write native cross-platform applications with Xamarin Design user interfaces that can be shared across Android, iOS, and Windows Phone using Xamarin. Forms Practical cross-platform development strategiesWho This Book Is ForIf you are a developer with experience in C# and are just getting into mobile development, this is the book for you. This book will give you a head start with cross-platform development and will be the most useful to developers who have experience with desktop applications or the web. What You Will Learn Apple's MVC design pattern The Android activity lifecycle Share C# code across platforms and call native Objective-C or Java libraries from C# Create a real web service back end in Windows Azure using SQL Azure as database storage Set up third-party libraries such as NuGet and Objective Sharpie in many different ways, and port a desktop .NET library to Xamarin Use Xamarin. Mobile for camera, contacts, and locationIn DetailXamarin is a leading cross-platform application development tool used by top companies such as Coca-Cola, Honeywell, and Alaska Airlines to build apps. Version 4 features significant updates to the platform including the release of Xamarin. Forms 2.0 and improvements have been made to the iOS and Android designers. Xamarin was acquired by Microsoft so it is now a part of the Visual Studio family. This book will show you how to build applications for iOS, Android, and Windows. You will be walked through the process of creating an application that comes complete with a back-end web service and native features such as GPS location, camera, push notifications, and other core features. Additionally, you'll learn how to use external libraries with Xamarin and Xamarin. Forms to create user interfaces. This book also provides instructions for Visual Studio and Windows. This edition has been updated with new screenshots and detailed steps to provide you with a holistic overview of the new features in Xamarin 4. Style and approachThis book offers a tutorial style approach to teach you the skills required to develop end-to-end cross-platform solutions with Xamarin About This BookWrite native cross-platform applications with XamarinDesign user interfaces that can be shared across Android, iOS, and Windows Phone using Xamarin.FormsPractical cross-platform development strategiesWho This Book Is ForIf you are a developer with experience in C# and are just getting into mobile development, this is the book for you. This book will give you a head start with cross-platform development and will be the most useful to developers who have experience with desktop applications or the web.What You Will LearnApple's MVC design patternGet to grips with the Android activity lifecycleShare the C# code across platforms and call the native Objective-C or Java libraries from C#Create a real web service backend in Windows Azure using Azure functionsSet up third-party libraries in different ways: portable.NET libraries from NuGet, bind Objective-C libraries with Objective Sharpie, and port a desktop.NET library to XamarinUse Xamarin.Mobile for camera, contacts, and locationIn DetailXamarin is a leading cross-platform application development tool used by top companies, such as Coca-Cola, Honeywell, and Alaska Airlines, to build apps. In version 4, there are significant updates to the platform, including the release of Xamarin.Forms 2.0; improvements have been made to the iOS and Android designers. With Xamarin being acquired by Microsoft, it is now a part of the Visual Studio family.This book takes a step-by-step approach in teaching you how to build applications for iOS and Android. We will walk you through a popular application, complete with a backend web service and native features, such as GPS location, camera, push notifications, and other core features. Additionally, you'll learn how to use external libraries with Xamarin and Xamarin.Forms to create user interfaces. We also provide instructions for Visual Studio and Windows. This edition has been updated with new screenshots and detailed steps to provide you with a holistic overview of the new features incorporated in Xamarin 4.