In app message notifications - KaleyraVideo/VideoiOSSDK GitHub Wiki

When a message is received, there is the possibility to see a custom in-app notification view.

Table of contents:

Overview

Starting from version 1.5.0 the MessageNotificationController is deprecated. If you are targeting the 1.5.0 version or a newer version of the BandyerSDK you should take a look at the In-app notifications guide instead.

To enable this feature, you must use the MessageNotificationController class, following those steps.

  1. Reference the controller inside your view controller.
  2. Alloc and init it.
  3. Setup it inside viewDidLoad.
  4. Call show/hide methods.

The MessageNotificationController

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


@interface MyViewController()

@property (nonatomic, strong) BCHMessageNotificationController *messageNotificationController;

@end

@implementation MyViewController

- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        _messageNotificationController = [BCHMessageNotificationController new];
    }

    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.messageNotificationController.delegate = self;
    self.messageNotificationController.parentViewController = self;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [self.messageNotificationController show];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self.messageNotificationController hide];
}

#pragma mark - Message Notification Controller delegate

- (void)messageNotificationController:(BCHMessageNotificationController *)controller didTouch:(BCHChatNotification *)notification
{
    //This delegate method is invoked when the user press the in app-notification view.
    //Present BCHChannelViewController.
}

@end
class MyViewController: UIViewController {

    private let messageNotificationController = MessageNotificationController() 

    //Setup it inside viewDidLoad.
    override func viewDidLoad() {
        super.viewDidLoad()
    
        messageNotificationController.delegate = self
        messageNotificationController.parentViewController = self
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
  
        messageNotificationController.show()
    }

    override public func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)

        messageNotificationController.hide()
    }
}

//MARK: Message notification controller delegate
extension MyViewController: MessageNotificationControllerDelegate {

    public func messageNotificationController(_ controller: MessageNotificationController, didTouch notification: ChatNotification) {
        //This delegate method is invoked when the user press the in app-notification view.
        //Present ChannelViewController.
    }
}

That's it! the steps you've seen are the only steps required to show in-app message notifications.

Where to go from here

The next guide Customizing user information will show you how customize appearance of message notification view. Also, if you haven't already, we suggest you to take a look at our sample apps (objective-c swift) to see how to show in-app notification.

What's next