Skip to content

HvrlK/MyEOSWalletSDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My EOS Wallet SDK

My EOS Wallet SDK allows iOS client apps to:

  • Get EOS Account: Request EOS Authorization for an EOS Account.
  • Transfer EOS: Send EOS and EOS Tokens.
  • Communicate via Simple Wallet: DApp can interact with wallet via Simple Wallet protocol

Installation

Step 1: Add framework

CocoaPods
  1. Add pod 'MyEOSWalletSDK', :git => 'https://github.com/HvrlK/MyEOSWalletSDK.git', :branch => '0.0.3' to Podfile
  2. Run pod install

Step 2: Configure Info.plist

  1. In Xcode, right-click your project's Info.plist file and select Open As -> Source Code.
  2. Insert the following XML snippet into the body of your file just before the final element. (URL type can also be added via Xcode in TARGETS -> {your target} -> Info tab -> URL Types)
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleURLName</key>
        <string>{YOUR BUNDLE ID}</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>{YOUR APP SCHEME}</string>
        </array>
    </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>myeoswallet</string>
</array>

Step 3: Configure SDK in AppDelegate

Setup is required before accessing MyEOSWalletSDK.shared instance

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    MyEOSWalletSDK.setup()
}

Usage examples

Check if wallet is installed

MyEOSWalletSDK.shared.isWalletInstalled

Launch EOS Account request

let request = MyEOSWalletSDK.LoginRequest(appName: "Examples", // Your app name
                                       appIcon: "http://daramghaus.github.io/icontester/images/iTunesArtwork.png",
                                       appVersion: "1.0",
                                       appDescription: "Example description", // Your app description
                                       uuID: "web-4e2aedb8-9a59-427a-3971-43b6b5a06dab", // Needed only for Simple Wallet protocol
                                       loginUrl: nil, // Needed only for Simple Wallet protocol
                                       callbackUrl: "MyEOSWalletSDKExamples://eos.io") // URL scheme of your app
MyEOSWalletSDK.shared.login(request: request)

Launch EOS Transfer request

let request = MyEOSWalletSDK.TransferRequest(appName: "Examples", // Your app name
                                          appIcon: "http://daramghaus.github.io/icontester/images/iTunesArtwork.png",
                                          appVersion: "1.0",
                                          appDescription: "Example description", // Your app description
                                          to: "recepientacc", // Recepient account name
                                          amount: 0.0001,
                                          contract: "eosio.token",
                                          symbol: "EOS",
                                          precision: 4,
                                          memo: nil,
                                          callbackUrl: "MyEOSWalletSDKExamples://eos.io")  // URL scheme of your app
MyEOSWalletSDK.shared.transfer(request: request)

Read wallet response

Handle wallet response in AppDelegate

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        guard let result = MyEOSWalletSDK.shared.parseResult(from: url) else {
            print("Url result parse error")
            return false
        }
        switch result {
        case .login(let result):
            switch result {
            case .success(let success):
                let accountName = success.accountName
                print("Login success, account: \(accountName)")
            case .error(let error):
                print("Login error: \(error)")
            case .cancel:
                print("Login cancel")
            }
        case .transfer(let result):
            switch result {
            case .success(let success):
                let transactionId = success.transactionId
                print("Transfer success, transactionId: \(transactionId)")
            case .error(let error):
                print("Transfer error: \(error)")
            case .cancel:
                print("Transfer cancel")
            }
        }
        return true
    }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published