Skip to content

Framework facilitating social interactions outside an iOS app (invite contacts, share to social networks, rate the app...)

License

Notifications You must be signed in to change notification settings

macistador/SocialKit

Repository files navigation

SocialKit

Fetching user's' address book local contacts and built-in customizable screen for sending invitations or adding as friend.

Features

  • Accessing address book contacts
    • Service for safely fetching local address book contacts
    • BuiltIn SwiftUI customizable Contacts Picker
    • BuiltIn send text message
    • Include your own custom user to the ContactPicker
    • Enrich your custom users with address book matching data
    • Include permission pre-prompt and reoptin
    • Set custom CacheService to improve fetching performance
    • Set custom UploadContactsService to sync the address book contacts to your backend
    • Write sample with cache
  • Social sharing
    • Customizable SwiftUI sheet
    • Copy to clipboard, by message, native sheet or to social networks
    • Networks implemented: Instagram, WhatsApp, Telegram, Twitter, Messenger

Requirements

  • iOS 15.0+
  • Xcode 12.0+
  • Swift 5.5+

Installation

SwiftPackageManager

dependencies: [
    .package(url: "https://github.com/macistador/ContactsKit", from: "0.0.1")
]

Usage

ContactsPicker

BuiltIn SwiftUI View

let sections: [ContactsPickerSection<User>] = [.localContacts(title: "My Contacts",
                                                              actionKind: .sendMessage(title: "invite", body: "Hey buddy, join me to this cool app!"))]

ContactsPicker<User, EmptyView>(sections: sections) { contact, actionResult in
    print("Contact tapped: \(contact)")
}

Service only

do {
    let contacts = try await contactsSerivce.fetchAllLocalContacts()
} catch {
    print("An error occurred: \(error.localizedDescription)")
}

Social Sharing sheet

  let sharings: [Sharing] = [.clipboard(title: "Amazing title", symbol: "rocket", text: "amazing text"),
                             .social(app: .instagram("Amazing text", isURL: false))]
  SharingView(sharing: sharings) { result in
      switch result {
      case .clipboard:
          print("Content shared to clipboard")
      case .social(let socialApp):
          print("Content shared to \(socialApp)")
      case .message(let isSent):
          print("Message sent: \(isSent)")
      case .other(let isShared):
          print("Other: \(isShared)")
      }
  }

For more details you may take a look at the sample project.

Other packages

Meanwhile this library works well alone, it is meant to be complementary to the following app bootstrap packages suite:

Credits

SocialKit is developed and maintained by Michel-André Chirita. You can follow me on Twitter at @Macistador for updates.

License

SocialKit is released under the MIT license. See LICENSE for details.

About

Framework facilitating social interactions outside an iOS app (invite contacts, share to social networks, rate the app...)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages