Installation(Legacy)

Installation

Prerequisite

  • iOS 10.0 or above
  • Swift 5.0 or above

SDK Latest Version

CocoaPods Carthage compatible

Cocoapods

If you are new to Cocoapods, please visit here to install and integrate it with your project. After you integrate Cocoapods, add below a code snippet to your Podfile. Make sure to include use_frameworks! to the Podfile to ensure Channel Plugin is installed properly.

target YOUR_PROJECT_TARGET do
  use_frameworks!
  pod 'ChannelIO'
end

And then run following command in console

pod install --repo-update

Carthage

  1. If you are new to Carthage, install it from here
  2. Add github “zoyi/channel-plugin-ios” to your Cartfile.
  3. Run the following command in console under your project directory.
carthage update --platform iOS --no-use-binaries
  1. Go to your Xcode project’s General settings. Open <YOUR_XCODE_PROJECT_DIRECTORY>/Carthage/Checkouts/channel-plugin-ios in Finder and drag ChannelIO.framework to the Linked Frameworks and Libraries section in Xcode along with other dependencies under <YOUR_XCODE_PROJECT_DIRECTORY>/Carthage/Build/iOS. Make sure Copy items if needed is selected and click Finish.

  2. Add run script in build phase and add

/usr/local/bin/carthage copy-frameworks

then places all necessary frameworks under input Files section

$(SRCROOT)/Carthage/Build/iOS/ChannelIO.framework
...
...

Update info.plist

There is some configuration you need to do manually in your project. After clicking your target, click Info tab, and add following keys and values.

KeyValue
Privacy - Camera Usage DescriptionAccessing to camera in order to provide better user experience
Privacy - Photo Library Usage DescriptionAccessing to photo library in order to provide better user experience
Privacy - Photo Library Additions Usage DescriptionAccessing to photo library in order to save photos
Privacy - Microphone Usage DescriptionAccessing to microphone to record voice for video

Using ChannelIO

To use ChannelIO, you first need to obtain a pluingKey from Channel Desk. If you still do not have a pluginKey, please read this . With this key, you can start to use ChannelIO in your application immediately by using boot: method. You can either start ChannelIO with anonymous user or registered user.

Import framework

First of all, import ChannelIO into a file where you want to use.

import ChannelIO
#import <ChannelIO/ChannelIO-swift.h>

Initialization on AppDelegate

Before you use any of methods from ChannelIO, make sure you call initialize: method in application:didFinishLaunchingWithOptions: method.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    ChannelIO.initialize(application)
    return true
  }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [ChannelIO initialize:application];
  return YES;
}

Initialization On SceneDelegate

❗️

Initialization(On SceneDelegate)

After initialization on AppDelegate,
If you use SceneDelegate, you must call 'initialzeWindow' method on willConnectTo of SceneDelegate with 'strong variable'.(support ChannelIO version >= 7.0.8)

// SceneDelegate.swift

var channelWindow: UIWinodw?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
  guard let windowScene = (scene as? UIWindowScene) else { return }
  channelWindow = ChannelIO.initialzeWindow(with: windowScene)
 }
//  SceneDelegate.m

@interface SceneDelegate ()
@property (strong, nonatomic) UIWindow * channelWindow;
@end

@implementation SceneDelegate


- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
  _channelWindow = [ChannelIO initializeWindowWith:(UIWindowScene *)scene];
}
@end

Start with an anonymous user

In order to boot with an anonymous user, you need to create a ChannelPluginSettings object and set its pluginKey property with the pluginKey you obtain from Channel Desk. That's it! If you follow steps correctly, you will see the ChannelIO launcher button on your application.

let settings = ChannelPluginSettings()
settings.pluginKey = "YOUR_PLUGIN_KEY"

ChannelIO.boot(with: settings)
ChannelPluginSettings *settings = [[ChannelPluginSettings alloc] init];
[settings setPluginKey:@"YOUR_PLUGIN_KEY"];
  
[ChannelIO bootWith:settings profile:nil completion:nil];

Start with a registered user

Starting with a registered user isn't much different than an anonymous user. The difference is you only need to provide a memberId in ChannelPluginSettings object.

📘

Please set memberId when you are integrating for registered users.

We distinguish anonymous users and registered users based on userId property in ChannelPluginSettings.

You can pass any other information about the user into Profile object if you want (please refer Profile for more detail).

let settings = ChannelPluginSettings()
settings.pluginKey = "YOUR_PLUGIN_KEY"
settings.memberId = "memberId"
 
let profile = Profile()
profile.set(name: "Jason")

ChannelIO.boot(with:settings, profile: profile)
ChannelPluginSettings *settings = [[ChannelPluginSettings alloc] init];
[settings setPluginKey:@"YOUR_PLUGIN_KEY"];
[settings setMemberId:@"memberId"];

Profile *profile = [[Profile alloc] init];
[profile setWithName:@"Jason"];

[ChannelIO bootWith:settings profile:profile completion:nil];

Launcher visibility

We provide the default launcher and its visibility can be controlled by calling show: and hide: methods. You have to configure its visibility based on your view if you only want to display it on certain views.

ChannelIO.show(animated: true)
ChannelIO.hide(animated: true)
[ChannelIO showWithAnimated:YES];
[ChannelIO hideWithAnimated:YES];

Shutdown

To terminate ChannelIO (typically when a user logout from your application), simply call

ChannelIO.shutdown()
[ChannelIO shutdown];