Added screens in sample app for notification
Summary:
Added a basic communication flows and a button to trigger notification
{F142016937}
Reviewed By: jknoxville
Differential Revision: D10492428
fbshipit-source-id: b65fc46b3be695852f9197771a253d9e8596f328
This commit is contained in:
committed by
Facebook Github Bot
parent
74c1a24b86
commit
12d2af38f7
57
iOS/Sample/CommunicationDemoViewController.mm
Normal file
57
iOS/Sample/CommunicationDemoViewController.mm
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "CommunicationDemoViewController.h"
|
||||
#import <FlipperKitExamplePlugin/FlipperKitExamplePlugin.h>
|
||||
|
||||
@interface CommunicationDemoViewController()<FlipperKitExampleCommunicationResponderDelegate>
|
||||
@property (strong, nonatomic) NSMutableArray<NSString *> *messagesToDisplay;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *messageTextField;
|
||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||
@end
|
||||
|
||||
@implementation CommunicationDemoViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[FlipperKitExamplePlugin sharedInstance].delegate = self;
|
||||
}
|
||||
|
||||
- (IBAction)tappedTriggerNotification:(UIButton *)sender {
|
||||
[[FlipperKitExamplePlugin sharedInstance] triggerNotification];
|
||||
}
|
||||
|
||||
- (IBAction)tappedSendMessage:(UIButton *)sender {
|
||||
if (self.messageTextField.text.length > 0) {
|
||||
[[FlipperKitExamplePlugin sharedInstance] sendMessage:self.messageTextField.text];
|
||||
}
|
||||
}
|
||||
|
||||
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reusableCell"];
|
||||
cell.textLabel.text = self.messagesToDisplay[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.messagesToDisplay.count;
|
||||
}
|
||||
|
||||
- (void)messageReceived:(NSString *)msg {
|
||||
if (msg) {
|
||||
if (!self.messagesToDisplay) {
|
||||
self.messagesToDisplay = @[].mutableCopy;
|
||||
}
|
||||
[self.messagesToDisplay addObject:msg];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user