TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Dec 2016 |
Maintained by Asaf Manassen, Ilan Klein, Oded Betzalel, Anton Aleksandrov, Vitaly M.
Depends on: | |
BMSSecurity | ~> 2.0 |
FBSDKLoginKit | ~> 4.17.0 |
FBSDKCoreKit | ~> 4.17.0 |
This is the Facebook security component of the Swift SDK for IBM Bluemix Mobile Services.
The Bluemix Mobile Services Facebook authentication Swift SDK is available via Cocoapods.
To install, add the BMSFacebookAuthentication
pod to your Podfile.
use_frameworks!
target 'MyApp' do
platform :ios, '8.0'
pod 'BMSFacebookAuthentication'
end
After you update your Podfile, the pod's sources are added to your workspace. Copy the FacebookAuthenticationManager.swift
file from the BMSFacebookAuthentication
pod's source folder to your app folder. Then find the info.plist
file (typically located under Supporting files
folder of your project) and add the following data to the source code of info.plist
. Replace <YOUR_FACEBOOK_APP_ID>
and <YOUR_FACEBOOK_APP_NAME>
with the values for your app's Facebook data:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb<YOUR_FACEBOOK_APP_ID></string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string><YOUR_FACEBOOK_APP_ID></string>
<key>FacebookDisplayName</key>
<string><YOUR_FACEBOOK_APP_NAME> </string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth</string>
<string>fbauth2</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
Important: Do not to override any existing properties in the info.plist
file. If you have overlapping properties, merge your file manually with this segment.
When using Xcode 8.x, in order to use BMSFacebookAuthentication, you need to enable Keychain Sharing in your app. You can enable this feature in the Capabilities tab of your target.
To use the Bluemix Mobile Services Facebook authentication Swift SDK, add the following imports to the class which you want to use Facebook authentication it in:
import BMSCore
import BMSSecurity
Connectivity and interaction between your mobile app and the Bluemix services depends on the application ID and application route that are associated with Bluemix application.
The BMSClient and MCAAuthorizationManager API are the entry points for interacting with the SDK. You must invoke the following API before any other API calls:
MCAAuthorizationManager.sharedInstance.initialize(tenantId: tenantId, bluemixRegion: regionName)
This method is usually called in the application delegate of your mobile app.
You also need to define MCAAuthorizationManager as your authorization manager:
BMSClient.sharedInstance.authorizationManager = MCAAuthorizationManager.sharedInstance
Then register the delegate for Facebook's realm:
FacebookAuthenticationManager.sharedInstance.register()
Then add the following code to your app delegate:
func application(_ app: UIApplication,
open url: URL,
options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool{
return FacebookAuthenticationManager.sharedInstance.onOpenURL(app, open: url, options: options)
}
In order to logout the current logged in user, you can use the following code:
FacebookAuthenticationManager.logout(<callBack>)
To switch users, you must call this code and the user must logout from Facebook in their browser.
You can use 'pod try BMSFacebookAuthentication' to get a sample application. A readme file with details on how to run the sample application is available in the app's folder.
Copyright 2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.