SDK for interacting with the Microsoft Embedded Social service from inside your iOS app
Перейти к файлу
Sharad Agarwal c1de4c64b9
Merge pull request #779 from Microsoft/sharad/fixLicense
added missing DeveloperCodeOfConduct and License
2018-10-18 09:27:09 -07:00
Design Icon added 2017-11-10 11:11:57 +02:00
EditorConfig/Templates Wip. 2017-09-20 22:49:50 +03:00
EmbeddedSocial Implemented 2017-11-27 11:24:12 +02:00
EmbeddedSocial-Example some fixes for code signing; not done 2017-11-13 15:35:18 -08:00
EmbeddedSocial.xcodeproj changes to get builds to work 2017-11-14 15:43:58 -08:00
EmbeddedSocial.xcworkspace Shared schemes. Debug distribution. 2017-10-09 12:19:11 +03:00
EmbeddedSocialTests Implemented 2017-11-11 02:40:25 +02:00
EmbeddedSocialUITests Bugfix. Done. 2017-11-10 19:16:08 +02:00
HockeySDK-iOS include HockeyApp SDK for analytics. 2017-10-11 14:32:56 -07:00
Scripts Added missing file 2017-10-09 16:17:46 +03:00
Templates Wip. 2017-09-12 17:29:20 +03:00
fastlane changing iOS version to match Travis setup 2017-10-16 18:04:11 -07:00
.gitignore Included Podifle.lock into .gitignore . 2017-07-19 12:07:39 +03:00
.gitmodules fix url to Swift library 2017-10-16 16:34:18 -07:00
.swift-version Added local pods as source code. 2017-10-24 17:09:50 +03:00
.swiftlint.yml Merge with develop 2017-07-31 15:57:54 +03:00
.travis.yml attempt to fix travis CI errors 2017-10-16 16:51:51 -07:00
DeveloperCodeOfConduct.md added missing files 2018-10-18 09:16:28 -07:00
EmbeddedSocial.podspec Podspec updated 2017-11-02 12:33:22 +02:00
LICENSE added missing files 2018-10-18 09:16:28 -07:00
Podfile Merge with develop 2017-10-27 11:20:30 +03:00
README.md Merge branch 'master' into develop 2018-07-02 12:06:18 -07:00
Rambafile Renamed, wip. 2017-07-31 10:15:05 +03:00

README.md

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 opencode@microsoft.com with any additional questions or comments.