Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sviatoslavbmx committed Jan 25, 2022
1 parent f054e82 commit ff82731
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
9 changes: 3 additions & 6 deletions ButterflyMX Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,9 @@ extension AppDelegate {

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
CallsService.shared.pushNotificationToken = deviceToken

if BMXCoreKit.shared.isUserLoggedIn && CallNotificationTypeManager.shared.getCurrentCallNotificationType() == .pushNotification{
let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
UserDefaults.standard.set(token, forKey: "apnsDeviceToken")
UserDefaults.standard.synchronize()
}
let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
UserDefaults.standard.set(token, forKey: "apnsDeviceToken")
UserDefaults.standard.synchronize()
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
Expand Down
8 changes: 1 addition & 7 deletions ButterflyMX Demo/Controllers/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ class LoginViewController: UITableViewController {
let mainViewController = stb.instantiateViewController(withIdentifier: "MainTabController")
mainViewController.modalPresentationStyle = .overFullScreen
SVProgressHUD.dismiss()
self.present(mainViewController, animated: true, completion: {
guard let pushToken = CallsService.shared.getPushToken() else { return }
let token = pushToken.map { String(format: "%02.2hhx", $0) }.joined()

UserDefaults.standard.set(token, forKey: "deviceToken")
UserDefaults.standard.synchronize()
})
self.present(mainViewController, animated: true, completion: nil)
case .failure(let error):
print(error)
SVProgressHUD.showError(withStatus: error.localizedDescription)
Expand Down
2 changes: 1 addition & 1 deletion ButterflyMX Demo/Logic/CallStatusHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ class CallStatusHandler: BMXCall.CallStatusDelegate {
}

private func dismissIncomingCall() {
CallsService.shared.window?.rootViewController?.dismiss(animated: true)
incomingCallViewController?.dismiss(animated: true)
}
}
10 changes: 4 additions & 6 deletions ButterflyMX Demo/Logic/CallsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,10 @@ extension CallsService: PKPushRegistryDelegate, CXProviderDelegate {

func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
pushkitToken = pushCredentials.token
if BMXCoreKit.shared.isUserLoggedIn {
let token = pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined()

UserDefaults.standard.set(token, forKey: "deviceToken")
UserDefaults.standard.synchronize()
}

let token = pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined()
UserDefaults.standard.set(token, forKey: "deviceToken")
UserDefaults.standard.synchronize()
}

private func reportFailedCall(reason: CXCallEndedReason) {
Expand Down

0 comments on commit ff82731

Please sign in to comment.