-
Notifications
You must be signed in to change notification settings - Fork 0
Call banner 1.x
Starting from 1.2.0 version, the BandyerSDK allows the user to "leave" the call screen temporarely navigating back to the BandyerSDK host app. It goes without saying that user might want to navigate back to the call screen when they have finished handling their side task for which they left the call screen in the first place. When there is an ongoing call, your app should present a small banner reminding the user a call is in progress. This banner will also allow the user to come back to the call screen when touched. The CallBannerController handles all this logic for you, this guide will show you how use it.
To enable this feature, you must use the CallBannerController class, following these steps.
- Setup a CallBannerController instance
- Call show/hide methods at the appropriate moments
- Handle its events
Inside next code snippets you can find all the implementation required to enable the feature.
@interface MyViewController()
@property (nonatomic, strong) BDKCallBannerController *callBannerController;
@end
@implementation MyViewController
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
//1st we create a BDKCallBannerController instance, we will manage through the lifecycle of this view controller
_callBannerController = [BDKCallBannerController new];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//2nd we setup it inside viewDidLoad registering as its delegate, providing it the view controller it will use to show the call banner onto.
self.callBannerController.delegate = self;
self.callBannerController.parentViewController = self;
}
- (void)viewWillAppear:(BOOL)animated
{
//3rd we bind the banner lifecyle to the view controller lifecycle
[super viewWillAppear:animated];
[self.callBannerController show];
}
- (void)viewWillDisappear:(BOOL)animated
{
//4th don't forget to stop it when the view controller's view disappears.
[super viewWillDisappear:animated];
[self.callBannerController hide];
}
#pragma mark - Call Banner Controller delegate
//5th Handle the CallBannerController events
- (void)callBannerController:(BDKCallBannerController *_Nonnull)controller willHide:(BDKCallBannerView *_Nonnull)banner
{
//This method in invoked when the banner is going to be hidden.
//Here you should handle the state of your view controller accordingly, for example managing the status bar appearance.
}
- (void)callBannerController:(BDKCallBannerController *_Nonnull)controller willShow:(BDKCallBannerView *_Nonnull)banner
{
//This method in invoked when the banner is going to be shown.
//Here you should handle the state of your view controller accordingly, for example managing the status bar appearance.
}
- (void)callBannerController:(BDKCallBannerController *_Nonnull)controller didTouch:(BDKCallBannerView *_Nonnull)banner
{
//This method in invoked when the user thouches the banner.
//Here you should show the previously hidden CallWindow
}
@end
class MyViewController: UIViewController {
//1st we create a BDKCallBannerController instance, we will manage through the lifecycle of this view controller
private let callBannerController = CallBannerController()
//Setup it inside viewDidLoad.
override func viewDidLoad() {
super.viewDidLoad()
//2nd we setup it inside viewDidLoad registering as its delegate, providing it the view controller it will use to show the call banner onto.
callBannerController.delegate = self
callBannerController.parentViewController = self
}
//Manage the possibility to show/hide the banner view.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//3rd we bind the banner lifecyle to the view controller lifecycle
callBannerController.show()
}
override public func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
//4th don't forget to stop it when the view controller's view disappears.
callBannerController.hide()
}
}
// MARK: Call banner controller delegate
extension MyViewController: CallBannerControllerDelegate {
//5th Handle the CallBannerController events
public func callBannerController(_ controller: CallBannerController, willHide banner: CallBannerView) {
//This method in invoked when the banner is going to be hidden.
//Here you should handle the state of your view controller accordingly, for example managing the status bar appearance.
}
public func callBannerController(_ controller: CallBannerController, willShow banner: CallBannerView) {
//This method in invoked when the banner is going to be shown.
//Here you should handle the state of your view controller accordingly, for example managing the status bar appearance.
}
public func callBannerController(_ controller: CallBannerController, didTouch banner: CallBannerView) {
//This method in invoked when the user thouches the banner.
//Here you should show the previously hidden CallWindow
}
}
That's it! the steps you've seen are the only steps required to properly show the banner view.
Looking for other platforms? Take a look at Android, Flutter, ReactNative, Ionic / Cordova. Anything unclear or inaccurate? Please let us know by submitting an Issue or write us here.