Friendly Score iOS SDK delivers toolset for user scoring on iOS devices.


  • [x] handles authentication and communication to FriendlyScore servers
  • [x] provides beautiful and customizable user interface
  • [x] helps with connections to social networks
  • [x] controls needed permissions using built-in Permissions Manager


  • iOS 9.0+
  • Swift 3.0+


To integrate FriendlyScore iOS SDK in your project, you must use CocoaPods (specific instructions how to add CocoaPods can be found here). Include line below to your Podfile:

pod 'FriendlyScoreSDK'




Almost every single detail can be customized. Contact us if you want to change default color palette.

Text Labels

Every text label can be changed. Contact us if you want to change default text labels.


It is possible to use custom bold&normal font in FriendlyScore SDK. Two conditions must be fulfilled: * fonts must be added to your XCode project (detailed instructions can be found here) * font names should be included in configuration file (contact us if you want to change system fonts)

:clipboard: This simple snippet helps you obtain font names included in your project:

func printFonts() {
    let fontFamilyNames = UIFont.familyNames
    for familyName in fontFamilyNames {
        print("Font Family Name = [\(familyName)]")
        let names = UIFont.fontNames(forFamilyName: familyName)
        print("Font Names = [\(names)]")

:warning: If SDK won't be able to find given fonts, system font will be used.


SDK will use default loader (activity) view for inital loading of configuration and setup. You can change this behaviour and provide your custom class that conforms Loading protocol. Example below shows how to create own activity:

class MyLoader:UIView,Loading {
    var circle:UIView!
    public func stopAnimating() {

    public func startAnimating() {

    func animate() {
        let a:CGFloat = circle.alpha == 1 ? 0 : 1
        UIView.animate(withDuration: 0.2, animations: {
   = a
        }) { _ in
    override init(frame: CGRect) {
        super.init(frame: frame)

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

    func setup() {
        circle = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
        circle.layer.cornerRadius = 5
        circle.backgroundColor = UIColor.white
        circle.translatesAutoresizingMaskIntoConstraints = false

        let height = circle.heightAnchor.constraint(equalToConstant: 10)
        let width = circle.widthAnchor.constraint(equalToConstant: 10)
        let centerX = circle.centerXAnchor.constraint(equalTo: centerXAnchor)
        let centerY = circle.centerYAnchor.constraint(equalTo: centerYAnchor)

        NSLayoutConstraint.activate([width, height, centerX, centerY])

        backgroundColor =

It creates white circle on black background and adds some opacity animation. To actually invoke loader in SDK you have to pass it in FriendlyScoreViewController constructor like this:

let myLoader = MyLoader(), loader:myLoader)

Usage of FriendlyScoreViewController is explained in section below

:warning: Note that your custom loader will be constrained to edges of the screen.


Before using, import library to your project:

import FriendlyScoreSDK

In order to proper connection to FriendlyScore servers you need to provide credentials:

let credentials = FriendlyScore.Credentials(appId: "1004", sessionKey: nil)

If you wish add existing user, you should provide session key in credential object:

let credentials = FriendlyScore.Credentials(appId: "1004", sessionKey: "12345678905")

FriendlyScore iOS SDK is presented as modal UIViewController:

Completion handler

From now on, SDK takes control over user actions. Add completion handler to your code to be notified when score is ready:

FriendlyScore.completionHandler = { result in
    switch result {
    case .failure(let error):
    case .success(let user):
        print("User id: \(")

When succeed you will receive FriendlyScore.User object which contains score details:

public struct User {
    public var id:Int
    public var score:Int
    public var maxScore:Int
    public var scorePercent:Double
    public var data:Array<User.Data>
    public var avatarURL: URL?

Social data handler

SDK will calculate score for you but it's your resposibility to obtain all necessary access tokens for each social network. When user hits one of social network card, SDK will request for proper token. Example below shows how to manage this action for Google service:

FriendlyScore.socialDataHandler = { request in
    switch request.socialNetwork {
    case .google:
        //... getting google access token goes here
        let token = "83qltg1r4aok0n383qltg1r4aok-0n3llilli",
                                              expiresIn: 13423353,
                                              idToken: "29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8-vdG")
    default: break

If your client's configuration includes other networks remember to provide necessary tokens, like:

FriendlyScore.accessTokenHandler = { request in
    switch request.socialNetwork {
    case .facebook:
        let facebookToken = ...
    case .google:
        let googleToken = ...
    case .twitter:
        let twitterToken = ...
    case .linkedin:
        let linkedinToken = ...
    case .paypal:
        let paypalToken = ...

Few helpers and advices for getting tokens can be found in demo application.