Skip to content

Commit

Permalink
Updated to latest SDK version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarik committed Oct 12, 2020
1 parent 629a76b commit c6fbefa
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 75 deletions.
43 changes: 31 additions & 12 deletions ButterflyMX Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
1A8DF4A0225CB26800AB0393 /* DoorsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A8DF49E225CB26500AB0393 /* DoorsTableViewController.swift */; };
1A8DF4A2225CBAF000AB0393 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A8DF4A1225CBAF000AB0393 /* Colors.swift */; };
1A8DF4A3225CBAF500AB0393 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A8DF4A1225CBAF000AB0393 /* Colors.swift */; };
1AA0EBF525346AC700014316 /* Pods_ButterflyMX_Demo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32027CBCF42518A1AF728022 /* Pods_ButterflyMX_Demo.framework */; };
1AA6FBF9219B2A78002F7168 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA6FBF8219B2A78002F7168 /* Foundation.framework */; };
AFDE38E8B11921FBB0C8A980 /* Pods_ButterflyMX_Demo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32027CBCF42518A1AF728022 /* Pods_ButterflyMX_Demo.framework */; };
C3689694234CD51F003DED8D /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3689693234CD51F003DED8D /* AVFoundation.framework */; };
C3C2322C21F5C6B500A84483 /* BuildFile in Sources */ = {isa = PBXBuildFile; };
C3C2322C21F5C6B500A84483 /* (null) in Sources */ = {isa = PBXBuildFile; };
C3C2322D21F5C6B500A84483 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C1317219ADCEE003449F8 /* LoginViewController.swift */; };
C3C2322E21F5C6B500A84483 /* BuildFile in Sources */ = {isa = PBXBuildFile; };
C3C2322E21F5C6B500A84483 /* (null) in Sources */ = {isa = PBXBuildFile; };
C3C2322F21F5C6B500A84483 /* GradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A05268521F206F000F6D373 /* GradientView.swift */; };
C3C2323021F5C6B500A84483 /* IncomingCallViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A05267921F0CE9400F6D373 /* IncomingCallViewController.swift */; };
C3C2323221F5C6B500A84483 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C1302219AD954003449F8 /* AppDelegate.swift */; };
C3C2323321F5C6B500A84483 /* BuildFile in Sources */ = {isa = PBXBuildFile; };
C3C2323421F5C6B500A84483 /* BuildFile in Sources */ = {isa = PBXBuildFile; };
C3C2323321F5C6B500A84483 /* (null) in Sources */ = {isa = PBXBuildFile; };
C3C2323421F5C6B500A84483 /* (null) in Sources */ = {isa = PBXBuildFile; };
C3C2323521F5C6B500A84483 /* CallsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A05267421F0A60700F6D373 /* CallsService.swift */; };
C3C2323621F5C6B500A84483 /* Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C1315219ADC82003449F8 /* Extension.swift */; };
C3C2323821F5C6B500A84483 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA6FBF8219B2A78002F7168 /* Foundation.framework */; };
Expand Down Expand Up @@ -101,8 +101,8 @@
files = (
1AA6FBF9219B2A78002F7168 /* Foundation.framework in Frameworks */,
1A59B851234B529300E1E536 /* CallKit.framework in Frameworks */,
1AA0EBF525346AC700014316 /* Pods_ButterflyMX_Demo.framework in Frameworks */,
C3689694234CD51F003DED8D /* AVFoundation.framework in Frameworks */,
AFDE38E8B11921FBB0C8A980 /* Pods_ButterflyMX_Demo.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -241,6 +241,7 @@
buildConfigurationList = 1A1C1311219AD956003449F8 /* Build configuration list for PBXNativeTarget "ButterflyMX Demo" */;
buildPhases = (
BCE9E26107CC63DA3F3C4CF7 /* [CP] Check Pods Manifest.lock */,
C46D36148E2E99E20832DEE2 /* [CP] Prepare Artifacts */,
1A1C12FB219AD954003449F8 /* Sources */,
1A1C12FC219AD954003449F8 /* Frameworks */,
1A1C12FD219AD954003449F8 /* Resources */,
Expand Down Expand Up @@ -285,6 +286,7 @@
TargetAttributes = {
1A1C12FE219AD954003449F8 = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1200;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 0;
Expand Down Expand Up @@ -378,6 +380,23 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
C46D36148E2E99E20832DEE2 /* [CP] Prepare Artifacts */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ButterflyMX Demo/Pods-ButterflyMX Demo-artifacts-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Prepare Artifacts";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-ButterflyMX Demo/Pods-ButterflyMX Demo-artifacts-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ButterflyMX Demo/Pods-ButterflyMX Demo-artifacts.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -404,19 +423,19 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C3C2322C21F5C6B500A84483 /* BuildFile in Sources */,
C3C2322C21F5C6B500A84483 /* (null) in Sources */,
1A8DF4A0225CB26800AB0393 /* DoorsTableViewController.swift in Sources */,
C3C2322D21F5C6B500A84483 /* LoginViewController.swift in Sources */,
1A2CD59121F6310900515F51 /* AccountTableViewController.swift in Sources */,
C3C2322E21F5C6B500A84483 /* BuildFile in Sources */,
C3C2322E21F5C6B500A84483 /* (null) in Sources */,
C3C2322F21F5C6B500A84483 /* GradientView.swift in Sources */,
1A715B10225632290002772C /* UnitsViewController.swift in Sources */,
C3C2323021F5C6B500A84483 /* IncomingCallViewController.swift in Sources */,
1A715B0622561DE10002772C /* DoorTableViewCell.swift in Sources */,
1A8DF4A3225CBAF500AB0393 /* Colors.swift in Sources */,
C3C2323221F5C6B500A84483 /* AppDelegate.swift in Sources */,
C3C2323321F5C6B500A84483 /* BuildFile in Sources */,
C3C2323421F5C6B500A84483 /* BuildFile in Sources */,
C3C2323321F5C6B500A84483 /* (null) in Sources */,
C3C2323421F5C6B500A84483 /* (null) in Sources */,
C3C2323521F5C6B500A84483 /* CallsService.swift in Sources */,
C3C2323621F5C6B500A84483 /* Extension.swift in Sources */,
1A715B0E22562E280002772C /* UnitTableViewCell.swift in Sources */,
Expand Down Expand Up @@ -523,7 +542,7 @@
LIBRARY_SEARCH_PATHS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.butterflymx.sdk.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -652,7 +671,7 @@
LIBRARY_SEARCH_PATHS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.butterflymx.sdk.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:ButterflyMX Demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -61,8 +59,6 @@
ReferencedContainer = "container:ButterflyMX Demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:ButterflyMX Demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
Expand All @@ -61,8 +59,6 @@
ReferencedContainer = "container:ButterflyMX Demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
8 changes: 4 additions & 4 deletions ButterflyMX Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let stb = UIStoryboard(name: "Main", bundle: nil)
if BMXCore.shared.isUserLoggedIn {
if BMXCoreKit.shared.isUserLoggedIn {
var env = BMXEnvironment(backendEnvironment: .development)
switch UserDefaults.standard.string(forKey: "environment") {
case "sandbox":
Expand All @@ -29,15 +29,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
default:
break
}
BMXCore.shared.configure(withEnvironment: env)
BMXCoreKit.shared.configure(withEnvironment: env)
let mainViewController = stb.instantiateViewController(withIdentifier: "MainTabController")
window!.rootViewController = mainViewController
} else {
let loginViewController = stb.instantiateViewController(withIdentifier: "LoginViewController")
window!.rootViewController = loginViewController
}

BMXCore.shared.delegate = self
BMXCoreKit.shared.delegate = self

CallsService.shared.setupVoipPush()
requestAccessMicCamera(callback: { status in
Expand All @@ -48,7 +48,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if (url.host == "test") {
BMXCore.shared.handle(url: url)
BMXCoreKit.shared.handle(url: url)
}
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AccountTableViewController: UITableViewController {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 1 && indexPath.row == 0 {
SVProgressHUD.show()
BMXCore.shared.logoutUser(completion: { result in
BMXCoreKit.shared.logoutUser(completion: { result in
switch result {
case .success:
let stb = UIStoryboard(name: "Main", bundle: nil)
Expand Down
16 changes: 8 additions & 8 deletions ButterflyMX Demo/Controllers/IncomingCallViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ class IncomingCallViewController: UIViewController {
if microphoneIsEnabled {
microphoneIsEnabled = false
sender.setImage(UIImage(named: "button_mute_active"), for: .normal)
BMXCall.shared.muteMic()
BMXCallKit.shared.muteMic()
print("mute mic")
} else {
microphoneIsEnabled = true
sender.setImage(UIImage(named: "button_mute"), for: .normal)
BMXCall.shared.unmuteMic()
BMXCallKit.shared.unmuteMic()
print("unmute mic")
}
}

@IBAction func hangUpAction(_ sender: Any) {
BMXCall.shared.endCall()
BMXCallKit.shared.endCall()
}

@IBAction func openDoorAction(_ sender: Any) {
BMXCall.shared.openDoor()
BMXCallKit.shared.openDoor()
self.alert(message: "Door is open!")
}

Expand All @@ -74,11 +74,11 @@ class IncomingCallViewController: UIViewController {
sender.setImage(UIImage(named: "button_camera"), for: .normal)
self.selfVideoView.isHidden = true
self.cameraIsEnabled = false
BMXCall.shared.hideOutgoingVideo()
BMXCallKit.shared.hideOutgoingVideo()
} else {
self.selfVideoView.isHidden = false
self.cameraIsEnabled = true
BMXCall.shared.showOutgoingVideo()
BMXCallKit.shared.showOutgoingVideo()
sender.setImage(UIImage(named: "button_camera_active"), for: .normal)
}
}
Expand All @@ -104,7 +104,7 @@ class IncomingCallViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
BMXCall.shared.delegate = self
BMXCallKit.shared.delegate = self
setupUIData()
}

Expand All @@ -121,7 +121,7 @@ class IncomingCallViewController: UIViewController {
speakerButton.setImage(UIImage(named: "button_speaker_active"), for: .normal)
}

guard let call = BMXCall.shared.activeCall?.callDetails else { return }
guard let call = BMXCallKit.shared.activeCall?.callDetails else { return }

if let image = call.mediumUrl {
let imageData = NSData(contentsOf: URL(string: image)!)
Expand Down
8 changes: 4 additions & 4 deletions ButterflyMX Demo/Controllers/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class LoginViewController: UITableViewController {
@IBAction func singInAction(_ sender: Any) {
SVProgressHUD.show()
let env = BMXEnvironment(backendEnvironment: environmentType)
BMXCore.shared.configure(withEnvironment: env)
BMXCore.shared.authorize(withAuthProvider: authProvider, callbackURL: URL(string: "demoapp:https://test")!, viewController: self) { result in
BMXCoreKit.shared.configure(withEnvironment: env)
BMXCoreKit.shared.authorize(withAuthProvider: authProvider, callbackURL: URL(string: "demoapp:https://test")!, viewController: self) { result in
switch result {
case .success:
let stb = UIStoryboard(name: "Main", bundle: nil)
Expand All @@ -47,7 +47,7 @@ class LoginViewController: UITableViewController {
self.present(mainViewController, animated: true, completion: {
guard let pushToken = CallsService.shared.pushkitToken else { return }
let token = pushToken.map { String(format: "%02.2hhx", $0) }.joined()
BMXCore.shared.registerDevice(with: .voip(token: token), apnsSandbox: false) { result in
BMXCoreKit.shared.registerDevice(with: .voip(token: token), apnsSandbox: false) { result in
switch result {
case .success:
print("Success")
Expand All @@ -66,7 +66,7 @@ class LoginViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
UserDefaults.standard.set("development", forKey: "environment")
BMXCore.shared.delegate = self
BMXCoreKit.shared.delegate = self
authProvider = getBMXAuthProvider(for: environmentType)
SVProgressHUD.setDefaultStyle(.light)
}
Expand Down
20 changes: 10 additions & 10 deletions ButterflyMX Demo/Logic/CallsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ class CallsService: NSObject {

extension CallsService: PKPushRegistryDelegate, CXProviderDelegate {
func providerDidReset(_ provider: CXProvider) {
BMXCall.shared.endCall()
BMXCallKit.shared.endCall()
}

func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
pushkitToken = pushCredentials.token
if BMXCore.shared.isUserLoggedIn {
if BMXCoreKit.shared.isUserLoggedIn {
let token = pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined()
BMXCore.shared.registerDevice(with: .voip(token: token), apnsSandbox: false) { result in
BMXCoreKit.shared.registerDevice(with: .voip(token: token), apnsSandbox: false) { result in
switch result {
case .success(let data):
print(data)
Expand Down Expand Up @@ -128,7 +128,7 @@ extension CallsService: PKPushRegistryDelegate, CXProviderDelegate {
}

// Start processing the call by ButterflyMX SDK
BMXCall.shared.processCall(guid: guid) { result in
BMXCallKit.shared.processCall(guid: guid) { result in
switch result {
case .success(let call):

Expand Down Expand Up @@ -156,33 +156,33 @@ extension CallsService: PKPushRegistryDelegate, CXProviderDelegate {
}

func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
BMXCall.shared.previewCall(autoAccept: true)
BMXCallKit.shared.previewCall(autoAccept: true)
action.fulfill()
}

func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
BMXCall.shared.endCall()
BMXCallKit.shared.endCall()

incomingViewController?.dismiss(animated: true, completion: nil)
action.fulfill()
}

func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
if action.isMuted {
BMXCall.shared.muteMic()
BMXCallKit.shared.muteMic()
} else {
BMXCall.shared.unmuteMic()
BMXCallKit.shared.unmuteMic()
}

action.fulfill()
}

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
BMXCall.shared.connectSoundDevice()
BMXCallKit.shared.connectSoundDevice()
}

func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
BMXCall.shared.disconnectSoundDevice()
BMXCallKit.shared.disconnectSoundDevice()
}
}

Loading

0 comments on commit c6fbefa

Please sign in to comment.