Call banner (deprecated) - Bandyer/Bandyer-iOS-SDK GitHub Wiki

Deprecation Warning: The call banner has been deprecated in 2.5.0 version and it will be removed in a future release. You should read this guide only if you are integrating an older version of the SDK

Starting from 1.2.0 version, the BandyerSDK allows the user to "leave" the call screen temporarily 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. If you are looking for the 1.x version guide take a look here.

Table of contents:

Overview

To enable this feature, you must use the CallBannerController class, following these steps.

  1. Setup a CallBannerController instance
  2. Call show/hide methods at the appropriate moments
  3. Handle its events

The CallBannerController

Inside next code snippets you can find all the implementation required to enable the feature.

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 callBannerControllerWillHideBanner(_ controller: CallBannerController) {
       //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 callBannerControllerWillShowBanner(_ controller: CallBannerController) {
       //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 callBannerControllerDidTouchBanner(_ controller: CallBannerController) {
       //This method in invoked when the user thouches the banner.
       //Here you should show the previously hidden CallWindow
    }
}

@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)callBannerControllerWillHideBanner:(BDKCallBannerController *_Nonnull)controller
{
   //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)callBannerControllerWillShowBanner:(BDKCallBannerController *_Nonnull)controller
{
   //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)callBannerControllerDidTouchBanner:(BDKCallBannerController *_Nonnull)controller
{
   //This method in invoked when the user thouches the banner.
   //Here you should show the previously hidden CallWindow
}

@end

That's it! the steps you've seen are the only steps required to properly show the banner view.