Latest 2.0.7
Homepage https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-swift-security-facebookauthentication
License Apache License, Version 2.0
Platforms ios 8.0, requires ARC
Dependencies BMSSecurity, FBSDKLoginKit, FBSDKCoreKit
Authors

IBM Bluemix Mobile Services – Client SDK Swift Security -Facebook

This is the Facebook security component of the Swift SDK for [IBM Bluemix Mobile Services] (https://console.ng.bluemix.net/docs/mobile/index.html).

Requirements

  • iOS 8.0 or later
  • Xcode 7 or later (XCode 8 for Swift 3 support)

Installation

The Bluemix Mobile Services Facebook authentication Swift SDK is available via Cocoapods.
To install, add the BMSFacebookAuthentication pod to your Podfile.

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

Enable Keychain Sharing

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.

Getting started

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.

Sample app

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.

Latest podspec

{
    "name": "BMSFacebookAuthentication",
    "version": "2.0.7",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "summary": "Authentication manager for connecting to IBM Bluemix Mobile Services Facebook protected resource",
    "homepage": "https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-swift-security-facebookauthentication",
    "license": "Apache License, Version 2.0",
    "authors": {
        "IBM Bluemix Services Mobile SDK": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-swift-security-facebookauthentication.git",
        "tag": "v2.0.7"
    },
    "documentation_url": "https://www.ng.bluemix.net/docs/#services/mobileaccess/index.html",
    "dependencies": {
        "BMSSecurity": [
            "~> 2.0"
        ],
        "FBSDKLoginKit": [
            "~> 4.17.0"
        ],
        "FBSDKCoreKit": [
            "~> 4.17.0"
        ]
    },
    "resources": "Source/FacebookAuthenticationManager.swift"
}

Pin It on Pinterest

Share This