Customization
Customizing channel button
Channel button position
You can configure the channel button's position by setting ChannelButtonOption
in BootConfig
and call boot
with that settings.
let config = BootConfig()
config.channelButtonOption = ChannelButtonOption(
position: .left,
xMargin: 100,
yMargin: 200
)
BootConfig *config = [BootConfig alloc] init];
ChannelButtonOption* option = [ChannelButtonOption alloc] initWithPosition: ChannelButtonPositionLeft xMargin:20 yMargin: 20];
[config setChannelButtonOption: option];
Channel button
If you want to customize the launcher button with your own implementation, you can implement your own button and call showMessenger
in a place where you control your button's touch events (In this case, you don't need to use showChannelButton
or hideChannelButton
which controls default launcher button's visibility).
Attention!
Don't foreget to set
delegate
property ofChannelIO
to proper object for delegate methods get called.
Unread Message Count
When implementing a customized launcher button, we recommend displaying a badge on it to alert your users of unread messages. To notify the changes of badge count, you need to implement onBadgeChanged
method in ChannelPluginDelegate
protocol.
class MyAwesomeApp: UIViewController {
func viewDidLoad() {
super.viewDidLoad()
ChannelIO.delegate = self
}
}
extension MyAwesomeApp : ChannelPluginDelegate {
func onBadgeChanged(count: Int) {
//do something with count
}
}
//in MyAwesomeApp.h
@interface MyAwesomeApp : UIViewController<ChannelPluginDelegate>
//your properties..
@end
//in MyAwesomeApp.m
@implementation MyAwesomeApp
- (void)viewDidLoad {
[super viewDidLoad];
ChannelIO.delegate = self;
}
- (void)onBadgeChangedWithCount:(NSInteger)count {
//do something with count
}
Customizing in-app push notification
In-app push notification view
By default, users will get in-app notification when a manager send a message through channel while they are active on your application. If you want to customize in-app notification view to fit your application theme, you need to set hidePopup
flag in BootConfig
to true
when you call boot:
.
Receiving in-app push notification
To receive push notification's information, implement onPopupDataReceived
delegate method in ChannelPluginDelegate
protocol.
class MyAwesomeApp: UIViewController {
func viewDidLoad() {
super.viewDidLoad()
ChannelIO.delegate = self
}
}
extension MyAwesomeApp: ChannelPluginDelegate {
func onPopupDataReceived(event: PopupData) {
//configure your view with push event data
//and display
}
}
//in MyAwesomeApp.h
@interface MyAwesomeApp : UIViewController<ChannelPluginDelegate>
//your properties..
@end
//in MyAwesomeApp.m
@implementation MyAwesomeApp
- (void)viewDidLoad {
[super viewDidLoad];
ChannelIO.delegate = self;
}
- (void)onPopupDataReceivedWithEvent:(PopupData *)event {
//configure your view with push event data
//and display
}
Log an event
You can log events with ChannelIO that records user behaviors in your application. For example, you can record a certain page users visited from your application and when they visited.
class MyAwesomeApp: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
ChannelIO.track(
eventName:"awesome_visited",
eventProperty: [
"visitedAt": "1521232131",
"hasClickedButtonA": true,
"otherMeta": "etc",
])
}
}
//in MyAwesomeApp.h
@interface MyAwesomeApp : UIViewController
//your properties..
@end
//in MyAwesomeApp.m
@implementation MyAwesomeApp
- (void)viewDidLoad {
[super viewDidLoad];
[ChannelIO trackWithEventName:@"awesome_visited" eventProperty:{
@"visitedAt": @"",
@"hasClickedButtonA": @(YES),
@"otherMeta": @"etc"
}];
}
Updated over 1 year ago