Customization
This page describes the custom options of ChannelIO iOS SDK (hereafter referred to as SDK).
Channel Button
This section describes the custom options of Channel Buttons.
1. Moving Channel Button
You can adjust the position of Channel button through ChannelButtonOption
.
After modifying this option, apply it to the property value of BootConfig
. For example:
let config = BootConfig()
config.channelButtonOption = ChannelButtonOption(
position: .left,
xMargin: 100,
yMargin: 200
)
ChannelIO.boot(with: config) {
...
}
BootConfig *config = [BootConfig alloc] init];
ChannelButtonOption* option = [ChannelButtonOption alloc] initWithPosition: ChannelButtonPositionLeft xMargin:20 yMargin: 20];
[config setChannelButtonOption: option];
2. Custom Channel Button
If you want to modify the appearance of the Channel button, you should make your own button.
- The default Channel button should not be visible, so call
ChannelIO.hideChannelButton
. - After creating its button and placing it at the desired location, connect the
ChannelIO.showMessenger
to the touch event of the button.
3. Display the number of unread messages
We recommend using onBadgeChanged
to show the number of unread messages. If you customize the Channel button, the number of unread messages is not exposed.
To implement this onBadgeChanged
, ChannelPluginDelegate
must be adopted. For example:
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 popup
This section describes How to customize in-app popup.
By default, the SDK sends the following in-app popup notifications to your app: This is valid when the user is online using the app.
1. information on the In-App popup
To receive in-app push notification, adopt ChannelPluginDelegate and implement the onPopupDataReceived method. Example include:
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
}
2. Custom Appearance In-App Popup Notification
To customize the In-App Push notification’s appearance, you must create and use your own in-app push notification screen.
- The default in-app push view should not be visible, so set
hidePopup
option ofBootConfig
totrue
. - Newly
Boot
with the aboveBootConfig
. - Use the
onPoupupDataReceived
method implemented in step 1 to fill in your own in-app push notification view.
Event tracking
This section describes the SDK’s custom event tracking.
1. Custom Event tracking
Use the track
method to track a specific action of the user.
The following is an example of logging an event when a user using the SDK approaches a specific ViewController MyAwesomeAppViewController
.
class MyAwesomeAppViewController: 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 8 months ago