The main goal of this blog is to show how to integrate Salesforce Sandbox environment with Azure Active Directory, using the Windows Azure AD single Sign-On configuration option. Before continuing, you should meet the following requirements: A valid Azure Active Directory Subscription A Sandbox environment on Salesforce .com with a System Admin user on this […]
This is an addon starter template for the Ionic Framework. The template installs a starter application that uses Salesforce OAuth to authenticate, and the Salesforce REST APIs to access and manipulate Salesforce data.
To use this starter pack, you’ll need to have installed Ionic and Cordova:
$ sudo npm install -g ionic cordova
Then, all you need to do is run:
$ ionic start myApp salesforce
Navigate (cd) to
myApp and run:
$ ionic platform add ios $ ionic build ios $ ionic emulate ios
Substitute ios for android, but if you can, the ios development toolchain is a lot easier to work with until you need to do anything custom to Android.
Because of the browser’s cross-origin restrictions, your Ionic application hosted on your own server (or localhost) will not be able to make API calls directly to the *.salesforce.com domain. The solution is to proxy your API calls through your own server. You can use your own proxy server or use ForceServer, a simple development server for Force.com. It provides two main features:
- A Proxy Server to avoid cross-domain policy issues when invoking Salesforce REST services. (The Chatter API supports CORS, but other APIs don’t yet)
- A Local Web Server to (1) serve the OAuth callback URL defined in your Connected App, and (2) serve the whole app during development and avoid cross-domain policy issues when loading files (for example, templates) from the local file system.
To run the application in the browser using ForceServer:
- Install ForceServer
$ sudo npm install -g force-server
- Navigate (cd) to your Ionic app’s www directory
- Start the server
This command will start the server on port 8200, and automatically load your app (http://localhost:8200) in a browser window. You’ll see the Salesforce login window (make sure you enable the popup), and the list of contacts will appear after you log in. If you don’t have a free Salesforce Developer Edition to log in to, you can create one here.
You can change the port number and the web root. Type the following command for more info:
This template uses forceng, a micro-library that makes it easy to use the Salesforce REST APIs in AngularJS applications. forceng allows you to easily login into Salesforce using OAuth, and to access your Salesforce data using a simple API.