Socially 0.0.2

Socially 0.0.2

Maintained by Phoe Lapyae.



Socially 0.0.2

Socially 🔐

Social Sign-In integration for SwiftUI

Version Swift License Platform

Features

  • Google Sign-In Integration
  • Facebook Sign-In Integration

Example

To run the example project, clone the repo, and run pod install from the Example directory first. You will need Google OAuth client ID and Facebook App ID. For Google, rename .plist file downloaded to credentials.plist and add to bundle. Then add your reversed client ID as a URL scheme. Check out https://developers.google.com/identity/sign-in/ios/start-integrating For Facebook, add Facebook App ID, Display Name, etc to Info.plist. Check out https://developers.facebook.com/docs/facebook-login/ios#4--configure-your-project

Requirements

  • iOS 13.0+
  • Xcode 11.5+
  • Swift 5.2+

Installation

Socially is available through CocoaPods. To install it, first run pod init in your project directory.

• Set up for Google

To set up Google Sign-In, you will need Google OAuth client ID. Go to this page and create client ID. Then open Podfile and add this.

pod 'Socially/Google'

Then run pod install in your project directory. Make sure to open .xcworkspace. You need to rename .plist file downloaded to credentials.plist and add to bundle. Then add your reversed client ID as a URL scheme. Finally, add Google.presentingViewController(window.rootViewController) after this line window.rootViewController = UIHostingController(rootView: contentView) in SceneDelegate.swift.

• Set up for Facebook

First of all, go to this page and create Facebook App ID. Add this to Podfile.

pod 'Socially/Facebook'

Then run pod install and open .xcworkspace. Then add Facebook App ID, Display Name, etc to Info.plist.

Simple Usage

Add init() to SwiftUI View

init() {
	SociallyAuth.setGoogleProvider(afterSignIn: { (_, user, _) in
		if let user = user {
			print(user.profile.name ?? "N/A")
		}
	})
}

Then you can use Sign-In function with the specific social sign-in inside SwiftUI Button. Currently, Socially is only available for Google and Facebook.

Button(action: {
	SociallyAuth.signIn(with: .google)
}) {
	Text("Sign In with Google")
}

You can easily add Sign-Out.

Button(action: {
	SociallyAuth.signOut()
}) {
	Text("Sign Out")
}

After launching the app, you can sign in silently with previous token.

.onAppear {
	SociallyAuth.restore()
}

Author

Phoe Lapyae

Follow me

License

Socially is available under the MIT license. See the LICENSE file for more info.