Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

.DS_Store

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xcuserstate

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
14 changes: 9 additions & 5 deletions sample-swift/SendBird-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
5ADEF82A1DAA663C000AABF9 /* CreateGroupChannelUserListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ADEF8291DAA663C000AABF9 /* CreateGroupChannelUserListTableViewCell.swift */; };
5ADEF82C1DAA67C5000AABF9 /* GroupChannelListEditableTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ADEF82B1DAA67C5000AABF9 /* GroupChannelListEditableTableViewCell.swift */; };
8F4B9B4CF66474515B5345D2 /* Pods_SendBird_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F3A2CB679067572774BDE5D /* Pods_SendBird_iOS.framework */; };
AB7DC7761E9D867300614891 /* SnapChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB7DC7751E9D867300614891 /* SnapChatViewController.swift */; };
CE806EF61E79048200A8CB57 /* IncomingVideoFileMessageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE806EF41E79048200A8CB57 /* IncomingVideoFileMessageTableViewCell.swift */; };
CE806EF71E79048200A8CB57 /* IncomingVideoFileMessageTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE806EF51E79048200A8CB57 /* IncomingVideoFileMessageTableViewCell.xib */; };
CE806EFA1E79049800A8CB57 /* OutgoingVideoFileMessageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE806EF81E79049800A8CB57 /* OutgoingVideoFileMessageTableViewCell.swift */; };
Expand Down Expand Up @@ -163,6 +164,7 @@
5ADEF82B1DAA67C5000AABF9 /* GroupChannelListEditableTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupChannelListEditableTableViewCell.swift; sourceTree = "<group>"; };
8F3A2CB679067572774BDE5D /* Pods_SendBird_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SendBird_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
96683C54D2DA7CFBF0C23471 /* Pods-SendBird-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SendBird-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-SendBird-iOS/Pods-SendBird-iOS.release.xcconfig"; sourceTree = "<group>"; };
AB7DC7751E9D867300614891 /* SnapChatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnapChatViewController.swift; sourceTree = "<group>"; };
C879E57358A8287C34B477A5 /* Pods-SendBird-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SendBird-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SendBird-iOS/Pods-SendBird-iOS.debug.xcconfig"; sourceTree = "<group>"; };
CE806EF41E79048200A8CB57 /* IncomingVideoFileMessageTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IncomingVideoFileMessageTableViewCell.swift; path = ../../GroupChannel/ViewCell/IncomingVideoFileMessageTableViewCell.swift; sourceTree = "<group>"; };
CE806EF51E79048200A8CB57 /* IncomingVideoFileMessageTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = IncomingVideoFileMessageTableViewCell.xib; path = ../../GroupChannel/ViewCell/IncomingVideoFileMessageTableViewCell.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -284,6 +286,7 @@
5ADEF8211DAA617D000AABF9 /* GroupChannelChattingViewController.xib */,
5AD94BA21DAF1A3A00A6CD66 /* MemberListViewController.swift */,
5AC2B6EC1DB61C1500BA4BC7 /* MemberListViewController.xib */,
AB7DC7751E9D867300614891 /* SnapChatViewController.swift */,
);
path = GroupChannel;
sourceTree = "<group>";
Expand Down Expand Up @@ -409,12 +412,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = SendBird;
TargetAttributes = {
5ABA0B7C1DA6010A000C82DC = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeam = 8K8M9F9X95;
DevelopmentTeam = 3W8D3S7TCY;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -568,6 +571,7 @@
5AD94C2C1DB5F74A00A6CD66 /* Bundle+SendBird.swift in Sources */,
5AD94BB91DAF24AD00A6CD66 /* OpenChannelListTableViewCell.swift in Sources */,
5AD94BA11DAB878600A6CD66 /* GroupChannelChattingViewController.swift in Sources */,
AB7DC7761E9D867300614891 /* SnapChatViewController.swift in Sources */,
5ABA0BCC1DA65240000C82DC /* IncomingUserMessageTableViewCell.swift in Sources */,
5AD94BBB1DAF262C00A6CD66 /* ParticipantListTableViewCell.swift in Sources */,
5AD94BC51DAF6FA500A6CD66 /* ParticipantListViewController.swift in Sources */,
Expand Down Expand Up @@ -794,7 +798,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 8K8M9F9X95;
DEVELOPMENT_TEAM = 3W8D3S7TCY;
INFOPLIST_FILE = "SendBird-iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -810,14 +814,14 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 8K8M9F9X95;
DEVELOPMENT_TEAM = 3W8D3S7TCY;
GCC_OPTIMIZATION_LEVEL = s;
INFOPLIST_FILE = "SendBird-iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.sample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion sample-swift/SendBird-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

application.applicationIconBadgeNumber = 0

SBDMain.initWithApplicationId("9DA1B1F4-0BE6-4DA8-82C5-2E81DAB56F23")
SBDMain.initWithApplicationId("1B0C2F67-9D82-49DD-8DA8-FF067E6C4259")
SBDMain.setLogLevel(SBDLogLevel.debug)
SBDOptions.setUseMemberAsMessageSender(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import MobileCoreServices
import Photos
import NYTPhotoViewer

class GroupChannelChattingViewController: UIViewController, SBDConnectionDelegate, SBDChannelDelegate, ChattingViewDelegate, MessageDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
class GroupChannelChattingViewController: UIViewController, SBDConnectionDelegate, ChattingViewDelegate, MessageDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var groupChannel: SBDGroupChannel!

@IBOutlet weak var chattingView: ChattingView!
Expand All @@ -25,7 +25,7 @@ class GroupChannelChattingViewController: UIViewController, SBDConnectionDelegat
@IBOutlet weak var imageViewerLoadingViewNavItem: UINavigationItem!

private var messageQuery: SBDPreviousMessageListQuery!
private var delegateIdentifier: String!
var delegateIdentifier: String!
private var hasNext: Bool = true
private var refreshInViewDidAppear: Bool = true
private var isLoading: Bool = false
Expand Down Expand Up @@ -72,7 +72,6 @@ class GroupChannelChattingViewController: UIViewController, SBDConnectionDelegat
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(notification:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)

self.delegateIdentifier = self.description
SBDMain.add(self as SBDChannelDelegate, identifier: self.delegateIdentifier)
SBDMain.add(self as SBDConnectionDelegate, identifier: self.delegateIdentifier)

self.chattingView.fileAttachButton.addTarget(self, action: #selector(sendFileMessage), for: UIControlEvents.touchUpInside)
Expand Down Expand Up @@ -119,7 +118,7 @@ class GroupChannelChattingViewController: UIViewController, SBDConnectionDelegat
}
}

@objc private func close() {
@objc func close() {
self.dismiss(animated: false) {

}
Expand Down Expand Up @@ -341,76 +340,6 @@ class GroupChannelChattingViewController: UIViewController, SBDConnectionDelegat
}
}

// MARK: SBDChannelDelegate
func channel(_ sender: SBDBaseChannel, didReceive message: SBDBaseMessage) {
if sender == self.groupChannel {
self.groupChannel.markAsRead()

self.chattingView.messages.append(message)
self.chattingView.chattingTableView.reloadData()
DispatchQueue.main.async {
self.chattingView.scrollToBottom(animated: true, force: false)
}
}
}

func channelDidUpdateReadReceipt(_ sender: SBDGroupChannel) {
if sender == self.groupChannel {
DispatchQueue.main.async {
self.chattingView.chattingTableView.reloadData()
}
}
}

func channelDidUpdateTypingStatus(_ sender: SBDGroupChannel) {
if sender == self.groupChannel {
if sender.getTypingMembers()?.count == 0 {
self.chattingView.endTypingIndicator()
}
else {
if sender.getTypingMembers()?.count == 1 {
self.chattingView.startTypingIndicator(text: String(format: Bundle.sbLocalizedStringForKey(key: "TypingMessageSingular"), (sender.getTypingMembers()?[0].nickname)!))
}
else {
self.chattingView.startTypingIndicator(text: Bundle.sbLocalizedStringForKey(key: "TypingMessagePlural"))
}
}
}
}

func channelWasChanged(_ sender: SBDBaseChannel) {
if sender == self.groupChannel {
DispatchQueue.main.async {
self.navItem.title = String(format: Bundle.sbLocalizedStringForKey(key: "GroupChannelTitle"), self.groupChannel.memberCount)
}
}
}

func channelWasDeleted(_ channelUrl: String, channelType: SBDChannelType) {
let vc = UIAlertController(title: Bundle.sbLocalizedStringForKey(key: "ChannelDeletedTitle"), message: Bundle.sbLocalizedStringForKey(key: "ChannelDeletedMessage"), preferredStyle: UIAlertControllerStyle.alert)
let closeAction = UIAlertAction(title: Bundle.sbLocalizedStringForKey(key: "CloseButton"), style: UIAlertActionStyle.cancel) { (action) in
self.close()
}
vc.addAction(closeAction)
DispatchQueue.main.async {
self.present(vc, animated: true, completion: nil)
}
}

func channel(_ sender: SBDBaseChannel, messageWasDeleted messageId: Int64) {
if sender == self.groupChannel {
for message in self.chattingView.messages {
if message.messageId == messageId {
self.chattingView.messages.remove(at: self.chattingView.messages.index(of: message)!)
DispatchQueue.main.async {
self.chattingView.chattingTableView.reloadData()
}
break
}
}
}
}

// MARK: ChattingViewDelegate
func loadMoreMessage(view: UIView) {
self.loadPreviousMessage(initial: false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="GroupChannelChattingViewController" customModule="SendBird_iOS" customModuleProvider="target">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SnapChatViewController" customModule="SendBird_iOS" customModuleProvider="target">
<connections>
<outlet property="bottomMargin" destination="5Ab-UI-o7I" id="7si-8B-fQY"/>
<outlet property="chattingView" destination="AAA-Vq-7hk" id="yX1-BT-ENu"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class GroupChannelListViewController: UIViewController, UITableViewDelegate, UIT
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
if self.editableChannel == false {
let vc = GroupChannelChattingViewController(nibName: "GroupChannelChattingViewController", bundle: Bundle.main)
let vc = SnapChatViewController(nibName: "GroupChannelChattingViewController", bundle: Bundle.main)
vc.groupChannel = self.channels[indexPath.row]
self.present(vc, animated: false, completion: nil)
}
Expand Down Expand Up @@ -302,7 +302,7 @@ class GroupChannelListViewController: UIViewController, UITableViewDelegate, UIT
// MARK: CreateGroupChannelUserListViewControllerDelegate
func openGroupChannel(channel: SBDGroupChannel, vc: UIViewController) {
DispatchQueue.main.async {
let vc = GroupChannelChattingViewController(nibName: "GroupChannelChattingViewController", bundle: Bundle.main)
let vc = SnapChatViewController(nibName: "GroupChannelChattingViewController", bundle: Bundle.main)
vc.groupChannel = channel
self.present(vc, animated: false, completion: nil)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import UIKit
import SendBirdSDK

class SnapChatViewController: GroupChannelChattingViewController, SBDChannelDelegate {
// JC TODO: Create timer to message deletion after a message is read by the recipient

override func viewDidLoad() {
super.viewDidLoad()

SBDMain.add(self as SBDChannelDelegate, identifier: self.delegateIdentifier)
}

// MARK: SBDChannelDelegate
func channel(_ sender: SBDBaseChannel, didReceive message: SBDBaseMessage) {
if sender == self.groupChannel {
self.groupChannel.markAsRead()

self.chattingView.messages.append(message)
self.chattingView.chattingTableView.reloadData()
DispatchQueue.main.async {
self.chattingView.scrollToBottom(animated: true, force: false)
}
}
}

func channelDidUpdateReadReceipt(_ sender: SBDGroupChannel) {
if sender == self.groupChannel {
DispatchQueue.main.async {
self.chattingView.chattingTableView.reloadData()
}
}

// JC TODO: Message read by recipient, start timer to delete message
// To get the last message, use sender.lastMessage
}

func channelDidUpdateTypingStatus(_ sender: SBDGroupChannel) {
if sender == self.groupChannel {
if sender.getTypingMembers()?.count == 0 {
self.chattingView.endTypingIndicator()
}
else {
if sender.getTypingMembers()?.count == 1 {
self.chattingView.startTypingIndicator(text: String(format: Bundle.sbLocalizedStringForKey(key: "TypingMessageSingular"), (sender.getTypingMembers()?[0].nickname)!))
}
else {
self.chattingView.startTypingIndicator(text: Bundle.sbLocalizedStringForKey(key: "TypingMessagePlural"))
}
}
}
}

func channelWasChanged(_ sender: SBDBaseChannel) {
if sender == self.groupChannel {
DispatchQueue.main.async {
self.navItem.title = String(format: Bundle.sbLocalizedStringForKey(key: "GroupChannelTitle"), self.groupChannel.memberCount)
}
}
}

func channelWasDeleted(_ channelUrl: String, channelType: SBDChannelType) {
let vc = UIAlertController(title: Bundle.sbLocalizedStringForKey(key: "ChannelDeletedTitle"), message: Bundle.sbLocalizedStringForKey(key: "ChannelDeletedMessage"), preferredStyle: UIAlertControllerStyle.alert)
let closeAction = UIAlertAction(title: Bundle.sbLocalizedStringForKey(key: "CloseButton"), style: UIAlertActionStyle.cancel) { (action) in
self.close()
}
vc.addAction(closeAction)
DispatchQueue.main.async {
self.present(vc, animated: true, completion: nil)
}
}

func channel(_ sender: SBDBaseChannel, messageWasDeleted messageId: Int64) {
if sender == self.groupChannel {
for message in self.chattingView.messages {
if message.messageId == messageId {
self.chattingView.messages.remove(at: self.chattingView.messages.index(of: message)!)
DispatchQueue.main.async {
self.chattingView.chattingTableView.reloadData()
}
break
}
}
}
}

}
Loading