The Channel Developers

Welcome to the Channel Developers. You'll find comprehensive guides and documentation to help you start working with Channel-docs as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

ChannelIO

initialize

Android
iOS

Initialize ChannelIO. You must call this method once.

Parameter

Description

Etc.

application

App application instance.

attachView

optional

Flag that determines whether to attach channel button and pop-up to all activities.
Set to false to disable the provided view.

default true

Android only

public class MyApp extends MultiDexApplication {
  @Override
  public void onCreate() {
    super.onCreate();
    
    ChannelIO.initialize(this);
  }
}


// to disable attaching channel button and popup
public class MyApp extends MultiDexApplication {
  @Override
  public void onCreate() {
    super.onCreate();
    
    ChannelIO.initialize(this, false);
  }
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ChannelIO.initialize(application)
    return true
  }
}
@implementation AppDelegate
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [ChannelIO initialize:application];
  return YES;
}

initializeWindow

iOS

return UIWindow

Parameter

Description

UIWindowScene

// 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.initializeWindow(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

delegate

iOS

Set delegate to receive events by ChannelIO

ChannelIO.delegate = self
ChannelIO.delegate = self;

setListener

Android

Attach listener to receive events by ChannelIO

Parameter

Description

listener

A event listener. See Listener / Delegate

public class MyApp extends MultiDexApplication, ChannelPluginListener {
  @Override
  public void onCreate() {
    super.onCreate();
    
    // some codes
    
    ChannelIO.setListener(this);
  }
}

clearListener

Android

Clear listener to stop receive events

ChannelIO.clearListener();

boot

Android
iOS

Start ChannelIO. Anywhere if you want.

About life cycle, See About lifecycle

Parameter

Description

bootConfig

Data structure that contains plugin key, user id, profiles, unsubscribed information, etc...

See more information BootConfig

bootCallback

optional

Callback that invoke boot is complete.
You can recognize boot is success or why failed.

See more information BootCallback

BootConfig bootConfig = BootConfig.create(YOUR_PLUGIN_KEY);

ChannelIO.boot(bootConfig, new BootCallback() {
  @Override
  public void onComplete(BootStatus bootStatus, @Nullable User user) {
    if (bootStatus == BootStatus.SUCCESS && user != null) {
      // success
    } else {
      // show failed reason from bootStatus
    }
  }
});
let bootConfig = BootConfig(pluginKey: YOUR_PLUGIN_KEY)

ChannelIO.boot(with: bootConfig) { (completion, user) in
    if completion == .success, let user = user {
        // success
    } else {
        // show failed reason from bootStatus
    }
}
BootConfig *bootConfig = [[BootConfig alloc] init];
[bootConfig setPluginKey:YOUR_PLUGIN_KEY];
[ChannelIO bootWith:bootConfig completion:^(BootStatus status, User *user) {
  if (status == BootStatusSuccess && user != nil) {
    // success
  } else {
    // show failed reason from bootStatus
  }
}];
const config = {
  "pluginKey": YOUR_PLUGIN_KEY,
  "memberId": MEMBER_ID,
  "memberHash": MEMBER_HASH,
  "profile": {
    "name": NAME,
    "email": EMAIL,
    "mobileNumber": "+~~~",
    "avatarUrl": AVATAR_URL,
    OTHER_KEY: OTHER_VALUE,
  },
  "language": LANGUAGE, // "en", "ko", "jp"
  "unsubscribed": BOOLEAN,
  "trackDefaultEvent": BOOLEAN,
  "hidePopup": BOOLEAN,
  "channelButtonOption": {
    "xMargin": 16,
    "yMargin": 16,
    "position": POSITION,  // "left", "right"
  },
}

ChannelIO.boot(config).then((result) => {
  // result.status
  // result.user
})

sleep

Android
iOS

Set ChannelIO only can receive push notification and track

About life cycle, See About life cycle

ChannelIO.sleep();
ChannelIO.sleep()
[ChannelIO sleep];
ChannelIO.sleep();

shutdown

Android
iOS

Stop interaction with ChannelIO
After calling shutdown, All of actions are not possible until boot is called.

About life cycle, See About life cycle

ChannelIO.shutdown();
ChannelIO.shutdown()
[ChannelIO shutdown];
ChannelIO.shutdown();

showChannelButton

Android
iOS

Show channel button globally.
It depend on boot state.

ChannelIO.showChannelButton();

// not shown
ChannelIO.boot(bootConfig, (bootStatus, user) -> {
  if (bootStatus == BootStatus.SUCCESS) {
    // shown
    // You can call it here instead of above.
  } else {
    // not shown
  }
});
ChannelIO.showChannelButton()

// not shown
ChannelIO.boot(with: bootConfig) { (completion, user) in
  if completion == .success, let user = user {
    // shown
    // You can call it here instead of above.
  } else {
    // not shown
  }
}
[ChannelIO showChannelButton];
  
// not shown
[ChannelIO bootWith:bootConfig completion:^(BootStatus status, User *user) {
  if (status == BootStatusSuccess && user != nil) {
    // shown
    // You can call it here instead of above.
  } else {
    // not shown
  }
}];
ChannelIO.showChannelButton();

hideChannelButton

Android
iOS

Hide channel button globally.
It depend on boot state.

When sleep, shutdown is called, channel button is hidden even if this function is not called.

ChannelIO.hideChannelButton();
ChannelIO.hideChannelButton()
[ChannelIO hideChannelButton];
ChannelIO.hideChannelButton();

showMessenger

Android
iOS

Open ChannelIO interaction UI.
This is the same operation as pressing the default channel button.
It depend on boot state.

Android needs activity instance

Parameter

Description

Etc

activity

Activity instance that based on Interaction UI

Android only

ChannelIO.showMessenger(activity);

// not shown
ChannelIO.boot(bootConfig, (bootStatus, user) -> {
  if (bootStatus == BootStatus.SUCCESS) {
    // shown
    // You can call it here instead of above.
  } else {
    // not shown
  }
});
ChannelIO.showMessenger()

// not shown
ChannelIO.boot(with: bootConfig) { (completion, user) in
  if completion == .success, let user = user {
    // shown
    // You can call it here instead of above.
  } else {
    // not shown
  }
}
[ChannelIO showMessenger]
  
// not shown
[ChannelIO bootWith:bootConfig completion:^(BootStatus status, User *user) {
  if (status == BootStatusSuccess && user != nil) {
    // shown
    // You can call it here instead of above.
  } else {
    // not shown
  }
}];
ChannelIO.showMessenger();

hideMessenger

Android
iOS

Close ChannelIO interaction UI when it is opened.
This is the same operation as pressing close button in interaction UI.

ChannelIO.hideMessenger();
ChannelIO.hideMessenger()
[ChannelIO hideMessenger];
ChannelIO.hideMessenger();

openChat

Android
iOS

Open chat directly.
See more case below.

Parameter

Description

Etc.

activity

Activity instance that based on Interaction UI

Android only

chatId

Chat id to go directly.
If chat id is invalid, go to lounge.

If chat id is null, open chat with parameter message See message parameter.

message

Preset text message when open empty user chat.
This parameter is valid when the chat id is null.

  • when null, open empty chat like click start new chat button in lounge.
// Open chat id is '123'
ChannelIO.openChat(activity, "123", null);

// Same as ChannelIO.openChat("123", null);
// When chat id parameter is not null, message parameter is ignored.
ChannelIO.openChat(activity, "123", "asd");

// Open new chat like click start new chat in lounge
ChannelIO.openChat(activity, null, null);

// Open new chat with "123" in input box. 
// If support bot is enabled, open support bot instead.
ChannelIO.openChat(activity, null, "123");
// Open chat id is '123'
ChannelIO.openChat(with: "123", message: nil)

// Same as ChannelIO.openChat("123", null);
// When chat id parameter is not null, message parameter is ignored.
ChannelIO.openChat(with: "123", message: "asd")

// Open new chat like click start new chat in lounge
ChannelIO.openChat(with: nil, message: nil)

// Open new chat with "123" in input box. 
// If support bot is enabled, open support bot instead.
ChannelIO.openChat(with: nil, message: "123")
// Open chat id is '123'
[ChannelIO openChatWith:@"123" message: nil]

// Same as ChannelIO.openChat("123", null);
// When chat id parameter is not null, message parameter is ignored.
[ChannelIO openChatWith:@"123" message: @"asd"]

// Open new chat like click start new chat in lounge
[ChannelIO openChatWith:nil message: nil]

// Open new chat with "123" in input box. 
// If support bot is enabled, open support bot instead.
[ChannelIO openChatWith:nil message: @"123"]
// Open chat id is '123'
ChannelIO.openChat("123", null);

// Same as ChannelIO.openChat("123", null);
// When chat id parameter is not null, message parameter is ignored.
ChannelIO.openChat("123", "asd");

// Open new chat like click start new chat in lounge
ChannelIO.openChat(null, null);

// Open new chat with "123" in input box. 
// If support bot is enabled, open support bot instead.
ChannelIO.openChat(null, "123");

track

Android
iOS

Add event for current user

SDK version, top activity name, screen size is default reserved.
You also call this method in sleep mode

Paramter

Description

eventName

Event name

max length is 30

properties

optional

Event properties.

// Only send event name
ChannelIO.track(EVENT_NAME);

// Event with properties
Map<String, Object> eventProperties = new HashMap<>();
eventProperties.put(PROPERTY_KEY_1, STRING_VALUE);
eventProperties.put(PROPERTY_KEY_2, INT_VALUE);

ChannelIO.track(EVENT_WITH_PROPERTIES_NAME, eventProperties);
// Only send event name
ChannelIO.track(eventName: EVENT_NAME, eventProperty: nil)

// Event with properties
var eventProperties: [String:Any] = [:]
eventProperties[PROPERTY_KEY_1] = STRING_VALUE
eventProperties[PROPERTY_KEY_2] = INT_VALUE
ChannelIO.track(eventName: EVENT_WITH_PROPERTIES_NAME, eventProperty: eventProperties)
// Only send event name
[ChannelIO trackWithEventName:@"EVENT_NAME" eventProperty:nil];
  
// Event with properties
NSDictionary<NSString *, id> *eventProperties = [NSMutableDictionary dictionary];
[eventProperties setValue:STRING_VALUE forKey:PROPERTY_KEY_1];
[eventProperties setValue:INT_VALUE forKey:PROPERTY_KEY_2];
[ChannelIO trackWithEventName:@"EVENT_WITH_PROPERTIES_NAME" eventProperty:eventProperties];
// Only send event name
ChannelIO.track(EVENT_NAME);

// Send event with properties
ChannelIO.track(
  EVENT_NAME, 
  { 
    PROPERTY_KEY_1: STRING_VALUE, 
    PROPERTY_KEY_2: INT_VALUE
  }
);

updateUser

Android
iOS

Update user.

There has a simple rules.

Parameter

Description

userData

User data to be updated.

See UserData

callback

Callback that informs you of the result of the API and updated user data.

See UserUpdateCallback

🚧

'UpdateUser' function has some different property from 'Boot' function.

Please check UserData

Map<String, Object> profileMap = new HashMap<>();

// name
profileMap.put("name", USER_NAME);

// mobileNumber
profileMap.put("mobileNumber", "+~~~");

// email
profileMap.put("email", EMAIL);

// avatar url
profileMap.put("avatarUrl", AVATAR_URL);

// other
profileMap.put(OTHER_KEY, OTHER_VALUE);

UserData userData = new UserData.Builder()
    .setLanguage(Language.ENGLISH)
    .setProfileMap(profileMap)
    .build();

ChannelIO.updateUser(userData, (e, user) -> {
  if (e == null && user != null) {
    // success, result data is user
  } else if (e != null) {
    // error, see e
  }
});
var profile: [String:Any] = [:]

// name
profile["name"] = USER_NAME
  
// mobileNumber
profile["mobileNumber"] = "+~~~"
  
// email
profile["email"] = EMAIL
  
// avatar url
profile["avatarUrl"] = AVATAR_URL
  
// other
profile[OTHER_KEY] = OTHER_VALUE
  
let userData = UpdateUserParamBuilder()
  .with(language: .english)
  .with(profile: profile)
  .build()
    
ChannelIO.updateUser(param: userData) { (error, user) in
  if let user = user, error == nil {
    // success, result data is user
  } else if let error = error {
    // error, see error
  }
}
UpdateUserParamObjcBuilder *builder = [[UpdateUserParamObjcBuilder alloc] init];

// name
[builder withProfileKey:@"name" value:USER_NAME];

// mobileNumber
[builder withProfileKey:@"mobileNumber" value:@"+~~~"];
  
// email
[builder withProfileKey:@"email" value:EMAIL];
  
// avatar url
[builder withProfileKey:@"avatarUrl" value:AVATAR_URL];
  
// other
[builder withProfileKey:@"OTHER_KEY" value:OTHER_VALUE];

[builder withLanguage:LanguageOptionEnglish];

[ChannelIO updateUserWithParam:[builder build] completion:^(NSError * error, User * user) {
  if (user != nil && error == nil) {
    // success, result data is user
  } else (error != nil) {
    // error, see error
  }
}];
const user = {
  "language": LANGUAGE, // "ko", "jp", "en"
  "tags": ["1", "2", "3"],
  "profile": {
    "name": NAME,
    "email": EMAIL,
    "mobileNumber": '+~~~',
    "avatarUrl": AVATAR_URL,
    OTHER_KEY: OTHER_VALUE,
  },
  "profileOnce": {
  },
  "unsubscribed": BOOLEAN,
};
ChannelIO.updateUser(user).then((result) => {
  // result.error
  // result.user
});

addTags

Android
iOS

Add tags to user.

Maximum tags size is 10.
A tag already added is ignored.
Tags are Case-insensitive (migrate to lower case)

null, list includes null, empty list, empty item is not allowed

Previous user's tag

Parameter

Result

["a"]

["b"]

["a", "b"]

null

["a", "b"]

["a", "b"]

["a", "c"]

["a", "b"]

["a", "b", "c"]

["a", "b", "c", "d", "e", "f", "g"]

["g", "h", "i", "j"]

["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

["a", "b", "c", "d", "e", "f", "g"]

["g", "h", "i", "j", "k"]

error: combined size is 11

Parameter

Description

tags

Tags to add

callback

Callback that informs you of the result of the API and updated user data.

See UserUpdateCallback

List<String> testTags = new ArrayList<>();
testTags.add("tag1");
testTags.add("tag2");
testTags.add("tag3");
testTags.add("tag4");

ChannelIO.addTags(testTags, (e, user) -> {
  if (user != null) {
    // success
  } else if (e != null) {
    // check reason
  }
});

// Simply, you can call like this
ChannelIO.addTags("a", "B"); // -> change to "a", "b"
var testTags: [String] = []
testTags.append("tag1")
testTags.append("tag2")
testTags.append("tag3")
testTags.append("tag4")

ChannelIO.addTags(testTags) { (error, user) in
  if let user = user {
    // success
  } else if error = error {
    // check reason
  }
}
NSMutableArray<NSString *> testTags = [NSMutableArray arrayWithCapacity:4];
[testTags addObject:@"tag1"];
[testTags addObject:@"tag2"];
[testTags addObject:@"tag3"];
[testTags addObject:@"tag4"];
  
[ChannelIO addTags:testTags completion:^(NSError * error, User * user) {
  if user != nil {
    // success
  } else if error != nil {
    // check reason
  }
}];
let tags = ["1", "2", "3"];
ChannelIO.addTags(tags).then((result) => {
  // result.error
  // result.user
});

removeTags

Android
iOS

Remove tags from user.

A tag which not exists is ignored.

null, list includes null, empty list, empty item is not allowed

Previous user's tag

Parameter

Result

["a", "b"]

["a"]

["b"]

["a"]

["c"]

["a"]

["a"]

["A", "c"]

null

thrid case "A" is same as "a"

tags

Tags to remove

callback

Callback that informs you of the result of the API and updated user data.

See UserUpdateCallback

List<String> testTags = new ArrayList<>();
testTags.add("tag1");
testTags.add("tag2");
testTags.add("tag3");
testTags.add("tag4");

ChannelIO.removeTags(testTags, (e, user) -> {
  if (user != null) {
    // success
  } else if (e != null) {
    // check reason
  }
});

// Simply, you can call like this
ChannelIO.removeTags("A", "B");
var testTags: [String] = []
testTags.append("tag1")
testTags.append("tag2")
testTags.append("tag3")
testTags.append("tag4")

ChannelIO.removeTags(testTags) { (error, user) in
  if let user = user {
    // success
  } else if error = error {
    // check reason
  }
}
NSMutableArray<NSString *> testTags = [NSMutableArray arrayWithCapacity:4];
[testTags addObject:@"tag1"]
[testTags addObject:@"tag2"]
[testTags addObject:@"tag3"]
[testTags addObject:@"tag4"]
  
[ChannelIO removeTags:testTags completion:^(NSError * error, User * user) {
  if user != nil {
    // success
  } else if error != nil {
    // check reason
  }
}];
let tags = ["1", "2"];
ChannelIO.removeTags(tags).then((result) => {
  // result.error
  // result.user
});

setPage

Android
iOS

Set page to be used instead of recent activity name or view controller.

See more about page?

setPage with null is different from resetPage. (that will send page data with null)

page

Page data to replace default page value

ChannelIO.setPage(page);
ChannelIO.setPage(page)
[ChannelIO setPage:page]
ChannelIO.setPage(page)

resetPage

Android
iOS

Reset page data customized by developer.

If you call resetPage, page data will fill with recent activity name.

ChannelIO.resetPage();
ChannelIO.resetPage()
[ChannelIO resetPage]
ChannelIO.resetPage()

initPushToken

Android
iOS

Save push token and send when now booted.

Parameter

Description

token

Push token

public class MyFirebaseMessagingService extends FirebaseMessagingService {
  @Override
  public void onNewToken(String refreshedToken) {
    ChannelIO.initPushToken(refreshedToken);
  }
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    ChannelIO.initPushToken(deviceToken: deviceToken)
  }
}
// AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

@property (nonatomic, strong) UIWindow *window;

@end


// AppDelegate.m
@implementation AppDelegate

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [ChannelIO initPushTokenWithDeviceToken:deviceToken.map]
}
import messaging from '@react-native-firebase/messaging';
import {ChannelIO} from 'react-native-channel-plugin';

componentDidMount() {
  this.onRefreshListener = messaging().onTokenRefresh(fcmToken => {
    ChannelIO.initPushToken(fcmToken);
  });
}

componentWillUnmount() {
  this.onRefreshListener();
}

isChannelPushNotification

Android
iOS

Check payload from push server is plugin's push notification

Parameter

Description

payload

public class MyFirebaseMessagingService extends FirebaseMessagingService {
  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    Map<String, String> messages = remoteMessage.getData();

    // This line
    if (ChannelIO.isChannelPushNotification(messages)) {
      ChannelIO.receivePushNotification(this, messages);
    }
  }
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {  
  @available(iOS 10.0, *)
  func userNotificationCenter(_ center: UNUserNotificationCenter,
                              didReceive response: UNNotificationResponse,
                              withCompletionHandler completionHandler: @escaping () -> Void) {
    let userInfo = response.notification.request.content.userInfo
    
    // This line
    if ChannelIO.isChannelPushNotification(userInfo) {
      ChannelIO.receivePushNotification(userInfo)
      ChannelIO.storePushNotification(userInfo)
    }
    completionHandler()
  }

    func application(_ application: UIApplication,
                     didReceiveRemoteNotification userInfo: [AnyHashable : Any],
                     fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    // This line
    if ChannelIO.isChannelPushNotification(userInfo) {
      ChannelIO.receivePushNotification(userInfo)
      ChannelIO.storePushNotification(userInfo)
    }
    completionHandler()
  }
}
//iOS 10 and above
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response 
withCompletionHandler:(void (^)())completionHandler {
    NSDictionary *userInfo = response.notification.request.content.userInfo;
  // This line
  if ([ChannelIO isChannelNotification:userInfo]) {
    [ChannelIO receivePushNotification:userInfo completion: nil];
    [ChannelIO storePushNotification: userInfo];
  }
  completionHandler();
}

//iOS 9 and others
- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  // This line
  if ([ChannelIO isChannelNotification:userInfo]) {
    [ChannelIO receivePushNotification:userInfo completion: ^{
      completionHandler(UIBackgroundFetchResultNoData);
    }];
    [ChannelIO storePushNotification: userInfo];
  } else {
    completionHandler(UIBackgroundFetchResultNoData);
  }
}
import messaging from '@react-native-firebase/messaging';
import {ChannelIO} from 'react-native-channel-plugin';

componentDidMount() {
    this.backgroundMessageHandler = messaging().setBackgroundMessageHandler(
      async (remoteMessage) => {
        ChannelIO.isChannelPushNotification(remoteMessage.data).then((result) => {
            if (result) {
              ChannelIO.receivePushNotification(remoteMessage.data).then((_) => { });
            } else {
              // TODO : Your FCM code
            }
          },
        );
      },
    );
}

componentWillUnmount() {
  this.backgroundMessageHandler();
}

receivePushNotification

Android
iOS

Send receive push notification event to ChannelIO server

+ Android
Show push notification

Parameter

Description

Etc.

context

Base context for android

Android only

payload

public class MyFirebaseMessagingService extends FirebaseMessagingService {
  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    Map<String, String> messages = remoteMessage.getData();

    if (ChannelIO.isChannelPushNotification(messages)) {
      // This line
      ChannelIO.receivePushNotification(this, messages);
    }
  }
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {  
  @available(iOS 10.0, *)
  func userNotificationCenter(_ center: UNUserNotificationCenter,
                              didReceive response: UNNotificationResponse,
                              withCompletionHandler completionHandler: @escaping () -> Void) {
    let userInfo = response.notification.request.content.userInfo
    
    if ChannelIO.isChannelPushNotification(userInfo) {
      // This line
      ChannelIO.receivePushNotification(userInfo)
      ChannelIO.storePushNotification(userInfo)
    }
    completionHandler()
  }

    func application(_ application: UIApplication,
                     didReceiveRemoteNotification userInfo: [AnyHashable : Any],
                     fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    if ChannelIO.isChannelPushNotification(userInfo) {
      // This line
      ChannelIO.receivePushNotification(userInfo)
      ChannelIO.storePushNotification(userInfo)
    }
    completionHandler()
  }
}
//iOS 10 and above
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response 
withCompletionHandler:(void (^)())completionHandler {
  NSDictionary *userInfo = response.notification.request.content.userInfo;
  if ([ChannelIO isChannelNotification:userInfo]) {
    // This line
    [ChannelIO receivePushNotification:userInfo completion: nil];
    [ChannelIO storePushNotification: userInfo];
  }
  completionHandler();
}

//iOS 9 and others
- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  if ([ChannelIO isChannelNotification:userInfo]) {
    // This line
    [ChannelIO receivePushNotification:userInfo completion: ^{
      completionHandler(UIBackgroundFetchResultNoData);
    }];
    [ChannelIO storePushNotification: userInfo]
  } else {
    completionHandler(UIBackgroundFetchResultNoData);
  }
}
import messaging from '@react-native-firebase/messaging';
import {ChannelIO} from 'react-native-channel-plugin';

componentDidMount() {
    this.backgroundMessageHandler = messaging().setBackgroundMessageHandler(
      async (remoteMessage) => {
        ChannelIO.isChannelPushNotification(remoteMessage.data).then((result) => {
            if (result) {
              ChannelIO.receivePushNotification(remoteMessage.data).then((_) => { });
            } else {
              // TODO : Your FCM code
            }
          },
        );
      },
    );
}

componentWillUnmount() {
  this.backgroundMessageHandler();
}

storePushNotification

iOS

Save push data to device

Parameter

Description

payload

Push notification payload from push messaging service

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {  
  @available(iOS 10.0, *)
  func userNotificationCenter(_ center: UNUserNotificationCenter,
                              didReceive response: UNNotificationResponse,
                              withCompletionHandler completionHandler: @escaping () -> Void) {
    let userInfo = response.notification.request.content.userInfo
    
    if ChannelIO.isChannelPushNotification(userInfo) {
      ChannelIO.receivePushNotification(userInfo)
      // This line
      ChannelIO.storePushNotification(userInfo)
    }
    completionHandler()
  }
//iOS 10 and above
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response 
withCompletionHandler:(void (^)())completionHandler {
  NSDictionary *userInfo = response.notification.request.content.userInfo;
  if ([ChannelIO isChannelNotification:userInfo]) {
    [ChannelIO receivePushNotification:userInfo completion: nil];
    // This line
    [ChannelIO storePushNotification: userInfo];
  }
  completionHandler();
}

hasStoredPushNotification

Android
iOS

Check plugin has latest clicked push data.

Parameter

Description

Etc.

activity

Base activity to start chat

Android only

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    // This line
    if (ChannelIO.hasStoredPushNotification(this)) {
      ChannelIO.openStoredPushNotification(this);
    }
  }
}
class ViewController : UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    
    // This line
    if (ChannelIO.hasStoredPushNotification()) {
      ChannelIO.openStoredPushNotification()
    }
  }
}
@implementation ViewController

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    
  // This line
  if ([ChannelIO hasStoredPushNotification]) {
        [ChannelIO openStoredPushNotification]
  }
}

@end
if (ChannelIO.hasStoredPushNotification()) {
  ChannelIO.openStoredPushNotification();
}

openStoredPushNotification

Android
iOS

Open chat by click push notification.
If status is sleeping or application restored, force boot by latest configuration.

Parameter

Description

Etc.

activity

Base activity to start chat

Android only

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (ChannelIO.hasStoredPushNotification(this)) {
      // This line
      ChannelIO.openStoredPushNotification(this);
    }
  }
}
class ViewController : UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    
    if ChannelIO.hasStoredPushNotification() {
      // This line
      ChannelIO.openStoredPushNotification()
    }
  }
}
@implementation ViewController

- (void)viewDidLoad { 
    [super viewDidLoad]; 

  if ([ChannelIO hasStoredPushNotification]) {
    // This line
    [ChannelIO openStoredPushNotification]
  }
}

@end
if (ChannelIO.hasStoredPushNotification()) {
  ChannelIO.openStoredPushNotification();
}

isBooted

Android
iOS

Check ChannelIO is booted

ChannelIO.isBooted();
ChannelIO.isBooted
ChannelIO.isBooted
ChannelIO.isBooted().then((result) => {
  // boolean
});

setDebugMode

Android
iOS

Set debug mode. Debug logs are shown.

Parameter

Description

flag

Debug flag

ChannelIO.setDebug(true);
ChannelIO.setDebugMode(with: true)
[ChannelIO setDebugModeWith:@(YES)]
ChannelIO.setDebugMode(true);

Updated 3 months ago

ChannelIO


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.