Crypttp-ios
Environment
iOS 10+
Instalation
1. In the Podfile of project add the following line
pod ‘CrypttpFramework’
After line added
pod install
2. Register universal link
Anywhere (between keys) in Info.plist add the following code.
Probably CFBundleURLTypes key is already exists, then you should add required shcema to array
1. Register crypttp link
2. Register your app link
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>crypttp</string>
<string>yourwalletname</string>
</array>
<key>CFBundleURLName</key>
<string></string>
</dict>
</array>
3. Register your app link in Crypttp system
Signup at Dashboard
Navigate to Settings/Wallet App
Set:
-
Name
-
Deeplink
-
Discription
-
Icon
-
Available currencies
-
Urls to AppStore
In addition this configuration will help us promote your wallet app.
Every user that has no wallet installed while paying at Crypttp merchants will be redirected to a special page where user can find featured wallets
4. Register first install handler
Get your merchant id in dashboard
let launchedBefore = UserDefaults.standard.bool(forKey: "launchedBefore")
if !launchedBefore {
if let url = URL(string: "https://api.crypttp.com/track/installation?id=<your merchant id>") {
UIApplication.shared.open(url, options: [:])
}
UserDefaults.standard.set(true, forKey: "launchedBefore")
}
Usage
1.
SDK methods are called through the Crypttp class.
guard let params = Crypttp.shared.parseCrypttpDeeplink(url: incomingURL) {
return false
}
returned value
public struct CrypttpTransactions {
let transactionId: String
let transactions: [CrypttpTransactionInfo]
}
public struct CrypttpTransactionInfo {
let coin: String
let amount: String
let to: String
let payload: String
let memo: String
let onSuccessUrl: String
let onFailureUrl: String
}
2.
In your successfull transaction handler add the following code:
Crypttp.shared.sendTransactionHash(transactionId:"id", transactionHash:"hash", success: {
print("success")
}) { error in
print("Error: \(error.localizedDescription)")
}
This method help us track paid transactions and provide statistics to our merchants.
Which in turn helps attract new merchants.
3.
After step 2.
add code to return user to the webpage or app from where user was routed to wallet.
That is important to provide good UX and to let merchant know that transaction was successfully made or failed
// for successfull case
if let url = URL(string: onSuccessUrl) {
UIApplication.shared.open(url, options: [:])
}
// for failed case
if let url = URL(string: onFailureUrl) {
UIApplication.shared.open(url, options: [:])
}