Here you can find instructions on how to integrate and use FriendlyScore Connect for iOS.
To get started quickly with FriendlyScore Connect for iOS, clone the GitHub repository and run the example. You will need to sign-up for the free API keys through our Developer Console.
- Xcode 10 or greater
- iOS 12.0 or greater
- FriendlyScore Client Id
Clone and run the demo project from our GitHub repository.
FriendlyScore Connect is a framework distributed using CocoaPods dependency manager. If you are not familiar with this concept, please follow detailed instructions here.
To integrate, add FriendlyScoreConnect to your Podfile
1
pod 'FriendlyScoreConnect', '~> 1.0.10'
Then run following command in your project main directory:
1
pod install
CocoaPods will install and embed all sources and dependencies into your app.
Start with importing FriendlyScoreCore and FriendlyScoreConnect framework in your App Delegate:
1
2
import FriendlyScoreCore
import FriendlyScoreConnect
Then configure Connect in application:didFinishLaunchingWithOptions:
1
2
3
4
5
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customisation after application launch.
FriendlyScore.configureConnect()
return true
}
In order to handle redirection properly, add line below to application(_:open:options:) function:
1
2
3
4
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
FriendlyScore.handleQueryParameters(for: url)
return true
}
Go to the Redirects section of the FriendlyScore developer console and provide your Bundle Identifier.
You will also need your Client Id for the specific environment (SANDBOX, PRODUCTION).
Navigate to your app target, create new URL Types object and add your bundle identifier to Identifier and URL Schemes field, as below:
Start by importing FriendlyScoreCore:
1
import FriendlyScoreCore
You can select which environment you want to use the FriendlyScore SDK and select the Client Id for that environment
Environment | Description |
---|---|
sandbox | Use this environment to test your integration |
production | Use this environment when deploying the live application |
Create the ClientId object
1
let myClientId = ClientId(stringLiteral: "YOUR_CLIENT_ID")
Create the Credentials object using userReference, which is any alphanumeric string that identifies the customer in your systems.
1
let myCredentials = Credentials(clientId: myClientId, userReference: "YOUR_USER_REFERENCE", environment: .sandbox)
Now, using the myCredentials object, you can present the FriendlyScore SDK anywhere in your code. Usually this can be done after the user's demand, e.g. tapping a button:
1
2
3
4
5
6
//somewhere in view controller
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 130, height: 45))
button.setTitle("Launch FriendyScore!", for: .normal)
button.addTarget(self, action: #selector(buttonTapHandler), for: .touchUpInside)
self.view.addSubview(button)
Theme
FriendlyScoreConnect can be presented with a light (default) or dark theme, which are predefined list of colors and icons.
To use custom colors for the categories, you must override the color keys in your application. Custom theme examples is included in the custom_theme.json. The color keys and descriptions are in the Colors section.
1
2
3
4
/*
Optional - Built-in themes = .light, .dark, .custom(themePath: String). Default theme is .light
*/
let connectTheme: ConnectTheme = .light
Other
1
2
3
4
5
6
7
8
9
10
/*
Optional - Set a flag whether to display only the back button on the screen with the list of banks. Default is true
*/
let showOnlyBackButtonIcon: Bool = true
/*
Optional - The label to show on the back button on the view with the list of banks to direct users back to your app. Default label is "Back". Ad
*/
let backButtonLabel: String = "Back"
Initiate FriendlyScore View with the options above
1
2
3
@objc func buttonTapHandler(button:UIButton) {
FriendlyScore.show(with: credentials, theme: .light, showOnlyBackButtonIcon: showOnlyBackButtonIcon, backButtonLabel: backButtonLabel)
}
Colors
Color Key | Description |
---|---|
connectBackgroundColor | Background color for all views in the SDK |
connectDividerColor | Divider color for all view in the SDK |
connectCancelButtonColor | Background color for Cancel, Disconnect Buttons |
connectNextButtonColor | Background color for Next, Confirm Button |
connectButtonTextColor | Text color for Buttons |
connectBankDetailMarkerColor | Color for the marker on the detail view for a connected bank |
connectNavigationButtonBackgroundColor | Background color for navigation button in the toolbar |
connectNavigationBackButtonItems | Color of the back button for the navigation button |
connectToolbarIconsColor | Color for the search icon in the toolbar |
connectToolbarTextColor | Color for the search field cursor |
connectToolbarSearchTextColor | Color for the search text query |
connectToolbarSearchCursorColor | Color for the search field cursor |
Color Key | Description |
---|---|
connectBankItemBackgroundColor | Background color for bank item in the list of banks |
connectBankItemTextColor | Text color for bank item in the list of banks |
connectBankItemDisabledTextColor | Text color for bank item if its disabled or not available in the list of banks |
connectBankItemBorderColor | Border color for the bank item in the list of banks |
connectedBankItemConnectedStatusColor | Color of the connected status icon for the bank item in the list of banks |
connectBankItemUnavailableStatusColor | Color of the unavailable status icon for the bank item in the list of banks |
Color Key | Description |
---|---|
connectFilterHeaderDisabledColor | Color for the filter header background color |
connectFilterPageTitleColor | Color for the filter header text color |
connectFilterPageSubTitleColor | Color for the filter item text color |
If you need to know when the user returns from the FriendlyScore Flow you must handle events
1
2
3
4
5
6
7
8
FriendlyScore.eventsHandler = { event in
switch event {
case .userClosedView:
print("SDK view closed by user.")
case .userCompletedFlow:
print("Friendly Score user completed flow.")
}
}
State | Definitions |
---|---|
userClosedView | Present if the customer Closed the FriendlyScore Flow. |
userCompletedFlow | Present if the customer Completed the FriendlyScore flow. |
If you need to know when the user returns from the FriendlyScore Flow you must handle errors
1
2
3
4
5
6
7
8
9
10
FriendlyScore.errorHandler = { error in
switch error {
case .userReferenceAuth:
print("There was an authentication error for the supplied `userReference`")
case .server: //unabled to get config
print("There was a critical error on the server. SDK view closed automatically")
case .serviceDenied: //wrong client id, access endpoint unpaid
print("The service you are trying to connect is denied. Reason: \(error.description). SDK view closed automatically")
}
}
Error | Definitions |
---|---|
userReferenceAuthError | Present if there was an authentication error for the supplied userReference. |
serviceDenied | Present if service was denied. Please check the description for more information. |
incompleteConfiguration | Present if the configuration on the server is incomplete. Please check the description for more information. |
serverError | Present if there was a critical error on the server. |
Was this article helpful?
Friendly Score UK Ltd.
42 Brook Street, Mayfair
London W1K 5DB
Call us on +44 20 3709 6726
Company registered in England
Company number 09168668, ICO ZA111687
VAT registration number 206 9758 80
Authorised and Regulated by the Financial Conduct Authority. (FRN: 821100, 781963)