SwiftyHelpKit 0.1.9

SwiftyHelpKit 0.1.9

anpkmr 维护。



 
依赖项
ObjectMapper= 3.4.2
Alamofire>= 0
FBSDKLoginKit= 4.34.0
FBSDKCoreKit= 4.34.0
FBSDKShareKit= 4.34.0
Google/SignIn>= 0
 

  • 作者
  • anpkmr

SwiftyHelpKit

CI Status Version License Platform

如何安装

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

屏幕截图:

需求

依赖

SwiftyHelpKit 依赖关系
  1. ObjectMapper
  2. Alamofire
  3. FBSDKLoginKit = 4.34.0
  4. FBSDKCoreKit = 4.34.0
  5. FBSDKShareKit = 4.34.0
  6. Google/SignIn

安装

SwiftyHelpKit 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'SwiftyHelpKit'

基本配置

Facebook 登录配置:

  1. 登录到 https://developers.facebook.com/ 并配置您的 App。 (例如,在设置页面上的 iOS 部分输入您的应用 Bundle id)
  2. 将 Facebook App ID 添加到您的项目中。

配置您的 info.plist

使用一个包含有关您的应用程序数据的 XML 片段配置信息属性列表文件 (info.plist)

1. 右键点击您的项目 info.plist 文件并作为源代码打开。 2. 现在将以下 XML 复制并粘贴到 info.plist 的主体中...

<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>

例如,像这样:- fbYOUR_APP_ID = fb1234567965412332222

  1. 使用Facebook对话框中的任何功能,请按照以下步骤修改您的info.plist文件:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
  1. 连接您的应用程序代理

// 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
}

Google Plus登录配置:

  1. 获取OAuth客户端ID

创建一个新的Google API项目并获取项目的iOS客户端ID。提示时,将YOUR_BUNDLE_ID(例如com.shkdemoapp.com)指定为包标识符。将下载的Google Service.plist文件添加到您的项目中。并确保选中目标成员。

  1. 连接您的应用程序代理
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))
}

如果有多个回调URL,请使用||分隔

  1. 设置回调URL类型:在执行登录之前,您需要在应用程序中添加一个回调URL。为添加回调URL,请转到项目的info标签,在URL类型部分中,在URL Schemes(您可以使用,添加多个方案)中添加您的REVERSE_CLIENT_ID(您可以在配置项目为Google开发者时下载的Google_server.plist文件中找到)。

  2. 现在使用以下代码在您的应用程序中进行Google登录:

SHKGooglePlusManager.sharedGoogleClient.setupGoogleLogin(self) { (socialUser, error) in
guard error == nil else {
print("Social user is====\(String(describing: socialUser?.firstName))")
return
}
}

作者:

anpkmr,[email protected]

许可证:

SwiftyHelpKit受MIT许可证的许可。有关更多信息,请参阅LICENSE文件。