diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8d7eb4494..62c0ae85c 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1230,8 +1230,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; content.categoryIdentifier = @"msg_cat"; + // save data to user info for rich notification content NSMutableArray *msgs = [NSMutableArray array]; - bctbx_list_t *history = linphone_chat_room_get_history(room, 3); + bctbx_list_t *history = linphone_chat_room_get_history(room, 4); while (history) { NSMutableDictionary *msgData = [NSMutableDictionary dictionary]; LinphoneChatMessage *msg = history->data; @@ -1250,9 +1251,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut [msgData setObject:fromImageData forKey:@"fromImageData"]; if (isFileTransfer) { // TODO + [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; } else { - const char *textMsg = linphone_chat_message_get_text_content(msg); - [msgData setObject:[NSString stringWithUTF8String:textMsg] forKey:@"msg"]; + [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; } [msgData setObject:[NSNumber numberWithBool:isOutgoing] forKey:@"isOutgoing"]; [msgs addObject:msgData]; diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index af13eb8f6..ced062366 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -64,6 +64,7 @@ 570742671D5A63DB004B9C84 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570742661D5A63DB004B9C84 /* StoreKit.framework */; }; 5E10ED4820D00630002BF6FE /* avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEBE61D3CD5570014B822 /* avatar.png */; }; 5E10ED4920D006C9002BF6FE /* chat_group_avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 8C2A81941F87B8000012A66B /* chat_group_avatar.png */; }; + 5E223A9920E244B400D06A36 /* NotificationTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E223A9820E244B400D06A36 /* NotificationTableViewCell.m */; }; 5E31290120D7A37E00CF3AAE /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EF0C33820C806A5005081B0 /* NotificationCenter.framework */; }; 5E31290520D7A37E00CF3AAE /* TodayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E31290420D7A37E00CF3AAE /* TodayViewController.m */; }; 5E31290820D7A37E00CF3AAE /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E31290620D7A37E00CF3AAE /* MainInterface.storyboard */; }; @@ -1077,6 +1078,8 @@ 570742601D5A09B8004B9C84 /* ShopView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopView.h; sourceTree = ""; }; 570742631D5A1860004B9C84 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/ShopView.strings; sourceTree = ""; }; 570742661D5A63DB004B9C84 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; + 5E223A9720E244B400D06A36 /* NotificationTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationTableViewCell.h; sourceTree = ""; }; + 5E223A9820E244B400D06A36 /* NotificationTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationTableViewCell.m; sourceTree = ""; }; 5E30780420D8F00D00256DAE /* latestChatroomsWidget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = latestChatroomsWidget.entitlements; sourceTree = ""; }; 5E31290020D7A37E00CF3AAE /* latestChatroomsWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = latestChatroomsWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 5E31290320D7A37E00CF3AAE /* TodayViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TodayViewController.h; sourceTree = ""; }; @@ -2535,6 +2538,8 @@ 5E58962920DCE5700030868C /* NotificationViewController.m */, 5E58962B20DCE5700030868C /* MainInterface.storyboard */, 5E58962E20DCE5710030868C /* Info.plist */, + 5E223A9720E244B400D06A36 /* NotificationTableViewCell.h */, + 5E223A9820E244B400D06A36 /* NotificationTableViewCell.m */, ); path = richNotifications; sourceTree = ""; @@ -4460,6 +4465,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5E223A9920E244B400D06A36 /* NotificationTableViewCell.m in Sources */, 5E58962A20DCE5700030868C /* NotificationViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index 7bfc6b3a5..67240e5cd 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -13,18 +13,66 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h new file mode 100644 index 000000000..0f15fa177 --- /dev/null +++ b/richNotifications/NotificationTableViewCell.h @@ -0,0 +1,15 @@ +// +// NotificationTableViewCell.h +// richNotifications +// +// Created by David Idmansour on 26/06/2018. +// + +#import + +@interface NotificationTableViewCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UIImageView *contactImage; +@property (weak, nonatomic) IBOutlet UILabel *nameDate; +@property (weak, nonatomic) IBOutlet UITextView *msgText; + +@end diff --git a/richNotifications/NotificationTableViewCell.m b/richNotifications/NotificationTableViewCell.m new file mode 100644 index 000000000..fb1853143 --- /dev/null +++ b/richNotifications/NotificationTableViewCell.m @@ -0,0 +1,25 @@ +// +// NotificationTableViewCell.m +// richNotifications +// +// Created by David Idmansour on 26/06/2018. +// + +#import "NotificationTableViewCell.h" + +@implementation NotificationTableViewCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code + _contactImage.layer.cornerRadius = _contactImage.frame.size.height / 2; + _contactImage.clipsToBounds = YES; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index e40e6ae9f..014b6178d 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -6,6 +6,7 @@ // #import "NotificationViewController.h" +#import "NotificationTableViewCell.h" #import #import @@ -25,7 +26,6 @@ - (void)didReceiveNotification:(UNNotification *)notification { msgs = [[[[notification request] content] userInfo] objectForKey:@"msgs"]; - printf("Taille tab : %d\n", (unsigned int)msgs.count); [self.tableView reloadData]; } @@ -48,8 +48,17 @@ display.UTF8String, msgText.UTF8String); printf("Taille de l'image de profil : %d\n", (unsigned int)imageData.length); - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath]; + NotificationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath]; + cell.contactImage.image = [UIImage imageWithData:imageData]; + cell.nameDate.text = display; + cell.msgText.text = msgText; return cell; } +#pragma mark - UITableViewDelegate Functions + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 100; +} + @end