PRODUCT_VIEW_README.md 2.35 KB
Newer Older
1 2
# Mobile Buy SDK - Product View

3
The SDK includes an easy-to-use product view to make selling simple in any app. The `ProductViewController` displays any product, it's images, price and details and includes a variant selection flow. It will even handle Apple Pay and web checkout automatically:
4 5

![Product View Screenshot](https://raw.github.com/Shopify/mobile-buy-sdk-ios/master/Assets/Product_View_Screenshot_1.png)
6

7
You can also theme the `ProductViewController` to better match your app and products being displayed:
8

9 10
![Product View Screenshot](https://raw.github.com/Shopify/mobile-buy-sdk-ios/master/Assets/Product_View_Screenshot_2.png)

11
Simply initialize the `ProductViewController` and present it from any view controller in your app to sell a product from you shop.
12 13 14

### Getting started

15
The `ProductViewController` needs a `BUYClient` setup with your shop's credentials to work, so first create a `BUYClient` object:
16 17 18 19 20 21 22

```objc
BUYClient *client = [[BUYClient alloc] initWithShopDomain:@"yourshop.myshopify.com"
                                                   apiKey:@"aaaaaaaaaaaaaaaaaa"
                                                channelId:@"99999"];
```

23
Now, create a `ProductViewController` with the `BUYClient`, and optionally add Apple Pay and a custom theme.
24 25 26 27 28 29 30

```objc
// Optionally customize the UI:
BUYTheme *theme = [[BUYTheme alloc] init];
theme.style = BUYThemeStyleLight;
theme.tintColor = [UIColor redColor];

31
ProductViewController *productViewController = [[ProductViewController alloc] initWithClient:self.client theme:theme];
32 33 34 35 36

// Optionally enable Apple Pay:
productViewController.merchantId = @"MERCHANT_ID";
```

37
Now the `ProductViewController` is ready to load a product and be presented in your app:
38 39 40 41 42 43 44 45 46 47 48

```objc
[productViewController loadProduct:@"PRODUCT_ID" completion:^(BOOL success, NSError *error) {
    if (success) {
        [self presentViewController:self.productViewController animated:YES completion:nil];
    } else {
        NSLog(@"Error: %@", error.userInfo);
    }
}];
```

Rune Madsen committed
49 50 51
If you have already loaded a product, you can call `loadWithProduct:completion:` instead. 

For a complete demo, check out the [Advanced Sample App](https://github.com/Shopify/mobile-buy-sdk-ios/tree/master/Mobile Buy SDK Sample Apps/Sample App Advanced/README.md), which demoes more UI customization with `BUYTheme` and both modal and navigation controller push presentations.