Giter Site home page Giter Site logo

botary / embeddedsocial-ios-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/embeddedsocial-ios-sdk

0.0 0.0 0.0 21.43 MB

SDK for interacting with the Microsoft Embedded Social service from inside your iOS app

License: MIT License

Shell 0.11% Swift 98.05% Ruby 0.24% Objective-C 0.03% Liquid 1.57%

embeddedsocial-ios-sdk's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.