All Projects → microsoft → EmbeddedSocial-iOS-SDK

microsoft / EmbeddedSocial-iOS-SDK

Licence: MIT License
SDK for interacting with the Microsoft Embedded Social service from inside your iOS app

Programming Languages

swift
15916 projects
Liquid
124 projects

Microsoft Embedded Social

iOS SDK

This is an SDK that works with the Microsoft Embedded Social service to provide social networking functionality inside your iOS application.

Requirements

  • iOS 9.0+
  • Xcode 8.3+
  • Swift 3.2

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods [--pre]

CocoaPods 1.4.0+ is required to build EmbeddedSocial SDK.

To integrate EmbeddedSocial SDK into your Xcode project using CocoaPods, specify it in your Podfile:

target '<Your Target Name>' do
  use_frameworks!

  pod 'EmbeddedSocial', :git => 'https://github.com/Microsoft/EmbeddedSocial-iOS-SDK.git', :branch => 'develop', :submodules => true
  
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
    	target.build_configurations.each do |config|
        	config.build_settings['SWIFT_VERSION'] = ‘3.2
        end
    end
end

Then, run the following command:

$ pod install

Usage

Info.plist

Insert the following lines in your Info.plist file in your project:

<key>LSApplicationQueriesSchemes</key>
<array>
	<string>fbapi</string>
	<string>fb-messenger-api</string>
	<string>fbauth2</string>
	<string>fbshareextension</string>
	<string>twitter</string>
	<string>twitterauth</string>
</array>

For Sign In functionality works, you should register your Application Bundle Identifier in:

After your Application registered, you will receive API keys. You should insert following lines in your Info.plist file:

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleURLSchemes</key>
		<array>
			<string> *YOUR FB APP KEY* </string>
		</array>
	</dict>
	<dict>
		<key>CFBundleURLSchemes</key>
		<array>
			<string> *YOUR TWITTER APP KEY* </string>
		</array>
	</dict>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string> *YOUR GOOGLE APP KEY* </string>
		</array>
	</dict>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
		</array>
	</dict>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string> *YOUR MICROSOFT APP KEY* </string>
      <string>auth</string>
      </array>
  </dict>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>embeddedsocial</string>
    </array>
  </dict>
</array>

AppDelegate.swift

Please, insert the following lines in your AppDelegate.swift file.

For SDK initialization:

func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
             
    let args = LaunchArguments(app: application,
                               window: window!,
                               launchOptions: launchOptions ?? [:],
                               menuHandler: SideMenuItemsProvider,
                               menuConfiguration: .tab)
    SocialPlus.shared.start(launchArguments: args)

    return true
}

For URL shemes handling:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
    return SocialPlus.shared.application(app, open: url, options: options)
}

For Push Notifications handling:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
    SocialPlus.shared.updateDeviceToken(devictToken: deviceTokenString)
}

func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable : Any]) {
    SocialPlus.shared.didReceiveRemoteNotification(data: data)
}

Advanced Usage

Menu

Menu Types

You can implement on of three menu types provided by SideMenuType:

public enum SideMenuType {
    case tab, dual, single
}

You can specify this in AppDelegate.swift with menuConfiguration parameter in LaunchArguments. For example:

let args = LaunchArguments(..., menuConfiguration: .tab | .dual | .single)

Menu Handler

You can implement your own menu items. You should make implementation for SideMenuItemsProvider:

public protocol SideMenuItemsProvider: class {
    func numberOfItems() -> Int
    func image(forItem index: Int) -> UIImage
    func imageHighlighted(forItem index: Int) -> UIImage
    func title(forItem index: Int) -> String
    func destination(forItem index: Int) -> UIViewController
}

You can handle this in AppDelegate.swift with menuHandler parameter in LaunchArguments. For example:

let menu: SideMenuItemsProvider = MyMenuImplementation()
let args = LaunchArguments(..., menuHandler: menu , ...)

Example

If you will have problems with SDK implementation, please, follow the Example Application.

License

By using this code, you agree to the Developer Code of Conduct, and the License Terms.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].