Create a Login with Amazon Project

If you do not yet have an app project for using Login with Amazon, you should create one now. If you have an existing app, skip to Install the Login with Amazon Library below.

Create a New Project in Xcode

  1. Launch Xcode.
  2. If you are presented with a Welcome to Xcode dialog, select Create a New Xcode Project. Otherwise, in the File menu, select New and Project.
  3. Select the type of project you wish to create and click Next.
  4. Enter a Product Name and a Company Identifier. Note your Bundle Identifier, and click Next.
  5. Select a location to store your project and click Create.

You will now have a new project that you can use to call Login with Amazon.

Install the Login with Amazon Library

If you have not yet downloaded the Login with Amazon SDK for iOS, see Install the Login with Amazon SDK for iOS.

A Login with Amazon project must link the LoginWithAmazon.framework and Security.framework libraries. You will also need to configure the framework search path to find the Login with Amazon headers.

  1. If your project doesn’t have a Frameworks folder, right-click the project name in the Navigator pane in Xcode, then click New Group.
  2. Name the new group Frameworks.
  3. Select the Frameworks folder and click File from the Main menu.
  4. Select Add Files to Project.
  5. In the dialog, select LoginWithAmazon.framework and click Add. If you used the Login with Amazon 1.0 library, delete the login-with-amazon-sdk directory and login-with-amazon-sdk.a from the Frameworks. Click Edit from the main menu and select Delete.
  6. Select the name of your project in the Project Navigator. The Project Editor will appear in the editor area of the Xcode workspace.
  7. Click your project name under Targets, and select Build Phases. Expand Link Binary with Libraries and click the plus sign to add a library.
  8. In the search box, type Security.framework. Select Security.framework and click Add.
  9. In the search box, type SafariServices.framework. Select SafariServices.framework and click Add.

    xcode link libraries
  10. Select Build Settings. Click All to view all settings.
  11. Under Search Paths, ensure that the LoginWithAmazon.framework directory is in the Framework Search Paths. For example:

    xcode header search paths
  12. Before building your project, if you used the Login with Amazon 1.0 library, replace #import "AIMobileLib.h", #import "AIAuthenticationDelegate.h", and #import "AIError.h" in your source files with a single #import <LoginWithAmazon/LoginWithAmazon.h>. The LoginWithAmazon.h line includes all the Login with Amazon headers at once. Additionally, you can remove any references to the 1.0 library path in the Header Search Paths or** Library Search Paths**.
  13. From the Main menu, click Product and select Build. The build should complete successfully.

Add your API Key to your App Property List

When you register your iOS application with Login with Amazon, you are assigned an API key . This is an identifier that the Amazon Mobile Library will use to identify your application to the Login with Amazon authorization service . The Amazon Mobile Library loads this value at runtime from the APIKey property value in your application’s Information Property List.

  1. With your project open, select the Supporting Files folder, then select the <project>-Info.plist file (where <project> is the name of your project). This should open the property list for editing:

    xcode API key
  2. Make sure none of the entries are selected. Then, in the main menu, click Editor, and Add Item. Type APIKey and press Enter.
  3. Double-click under the Value column to add a value. Paste your API Key as the value.

Add a URL Scheme to Your App Property List

When the user logs in, they will be presented with an Amazon login page. In order for your app to receive confirmation of their login, you must add a URL scheme so the web page can redirect back to your app. The URL scheme must be declared as amzn-<bundleID> (for example, amzn-com.example.app). For more information, see Using URL Schemes to Communicate with Apps on developer.apple.com.

  1. With your project open, select the Supporting Files folder, then select the <project>-Info.plist file (where <project> is the name of your project). This should open the property list for editing:

    xcode url scheme
  2. Make sure none of the entries are selected. Then, in the main menu, click Editor, and Add Item. Type or select URL types and press Enter.
  3. Expand URL types to reveal Item 0. Select Item 0 and, from the main menu, click Editor and Add Item. Type or select URL Identifier and press Enter.
  4. Select Item 0 under URL Identifier and double-click under the Value column to add a value. The value is your bundle ID. You can find your bundle ID listed as Bundle identifier in the property list.
  5. Select Item 0 under URL types and, from the main menu, click Editor and Add Item. Type or select URL Schemes and press Enter.
  6. Select Item 0 under URL Schemes and double-click under the Value column to add a value. The value is your bundle ID with amzn- prepended (for example, amzn-com.example.app). You can find your bundle ID listed as Bundle identifier in the property list.