To run the example project, clone the repo, and run pod install
from the Example directory first.
- ObjectMapper
- Alamofire
- FBSDKLoginKit = 4.34.0
- FBSDKCoreKit = 4.34.0
- FBSDKShareKit = 4.34.0
- Google/SignIn
SwiftyHelpKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SwiftyHelpKit'
- Login to https://developers.facebook.com/ and configure Your App with Facebook. (i.e. enter the Bundle id of your app in iOS section on the settings page)
- Add facebook App Id to your project.
Configure the information property list file (info.plist) with an XML snippet that contains data about your app.
1.Right click on your project's info.plist file and open it as source code. 2. Now copy and paste the follwign XML into your info.plist Body of ...
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbYOUR_APP_ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>YOUR_APP_ID</string>
<key>FacebookDisplayName</key>
<string>LetsTestApp</string>
For example like this:- fbYOUR_APP_ID = fb1234567965412332222
- To use any of the facebook dialog modify your info.plist file as
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
- Connect Your App Delegate
// AppDelegate.swift
import FBSDKCoreKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let handled: Bool = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options)
// Add any custom logic here.
return handled
}
- Get an OAuth client ID
Create a new Google API project and get an iOS client ID for the project. When prompted, specify YOUR_BUNDLE_ID(liek com.shkdemoapp.com) as the bundle ID. Add the download Google Service.plist file to your project. And make sure Target membership is checked.
- Connect Your App Delegate
import GoogleSignIn
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "YOUR_CLIENT_ID"
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return GIDSignIn.sharedInstance().handle(url,sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,annotation: (options[UIApplicationOpenURLOptionsKey.annotation] != nil))
}
If you have multiple call back url's seperate them with ||
-
Set the callback URL type Before sign in can run you need to add a callback url in your app. For adding callback url go to your project's info tab and in URL Types section add your REVERSE_CLIENT_ID(that you can found in your Google_server.plist file that you have donwloaded while congifuring your project to google developers) in URL Schemes (You can add multiple schems using ,)
-
Now use the following code to for the google login in your app
SHKGooglePlusManager.sharedGoogleClient.setupGoogleLogin(self) { (socialUser, error) in
guard error == nil else {
print("Social user is====\(String(describing: socialUser?.firstName))")
return
}
}
anpkmr, anup227kumar@gmail.com
SwiftyHelpKit is available under the MIT license. See the LICENSE file for more info.