iOS

Integrate Ramp Instant widget into your iOS application

The iOS SDK allows you to seamlessly open the Ramp Instant widget directly inside your app using WebViews. Your app will be able to receive events about the purchase made inside the widget.

Useful links:


Overview

Ramp Instant iOS SDK consists of two main types: RampInstantConfiguration and RampInstantManager.

RampInstantConfiguration contains all the information necessary for RampInstant to initialize.

  • hostLogoUrl: URL to your app's logo
  • hostAppName: your app's name
  • userAddress: 0x-prefixed ETH address of the buyer
  • swapAsset: 'ETH' or 'DAI' (optional)
  • swapAmount: int string - wei or token units (optional)
  • webhookStatusUrl: your URL for webhook updates (optional)
  • url: allows to provide an alternative URL to load a non-production version of the widget (optional)

RampInstantManager is the main class. It allows to present the RampInstant widget, listen for events, and log debug information.

  • init(configuration: RampInstantConfiguration): create instance of RampInstantManager with configuration of your choice
  • presentWidget(on viewController: UIViewController, animated: Bool): display RampInstant widget on any view controller

Example integration code

To start using RampInstant in your app, simply create a Configuration instance with parameters of your choice, then instantiate the RampInstantManager with the Configuration instance. Now you can present it anywhere!

// ...
import RampInstant

class ViewController: UIViewController {

    var rampInstantManager: RampInstantManager?

    // ...

    @IBAction func showRampInstantAction(_ sender: UIButton) {
        let configuration = RampInstant.Configuration(
            hostLogoUrl: "www.example.com/icon.png",
            hostAppName: "Example App Name",
            userAddress: "0xab5801a7d398351b8be11c439e05c5b3259aec9b",
            swapAsset: "ETH",
            swapAmount: "1500000000000000000", // 1.5 ETH in wei
            url: "https://ri-widget-dev.firebaseapp.com/" // Development version of the widget
        )

        rampInstantManager = RampInstantManager(configuration: configuration)
        rampInstantManager!.presentWidget(on: self, animated: true)
    }

    // ...
}