Merge pull request #353 from James-Sangalli/remove-notifications-settings

Remove push notifications in Settings
pull/355/head
James Sangalli 7 years ago committed by GitHub
commit 006ace82b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Trust.xcodeproj/project.pbxproj
  2. 12
      Trust/AppCoordinator.swift
  3. 3
      Trust/AppDelegate.swift
  4. 21
      Trust/Assets.xcassets/settings_push_notifications.imageset/Contents.json
  5. BIN
      Trust/Assets.xcassets/settings_push_notifications.imageset/settings_push_notifications.png
  6. 1
      Trust/Localization/en.lproj/Localizable.strings
  7. 1
      Trust/Localization/es.lproj/Localizable.strings
  8. 1
      Trust/Localization/zh-Hans.lproj/Localizable.strings
  9. 52
      Trust/Settings/Coordinators/PushNotificationsRegistrar.swift
  10. 8
      Trust/Settings/Coordinators/SettingsCoordinator.swift
  11. 1
      Trust/Settings/Types/SettingsAction.swift
  12. 19
      Trust/Settings/ViewControllers/SettingsViewController.swift

@ -16,7 +16,6 @@
290B2B6A1F92C0440053C83E /* ConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290B2B691F92C0440053C83E /* ConfigTests.swift */; };
290B2B6C1F92C35B0053C83E /* RPCServerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290B2B6B1F92C35B0053C83E /* RPCServerTests.swift */; };
290B2B6E1F92C3980053C83E /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290B2B6D1F92C3980053C83E /* UserDefaults.swift */; };
290B2B701F930AB90053C83E /* PushNotificationsRegistrar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290B2B6F1F930AB90053C83E /* PushNotificationsRegistrar.swift */; };
2912CCF91F6A830700C6CBE3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2912CCF81F6A830700C6CBE3 /* AppDelegate.swift */; };
2912CD021F6A830700C6CBE3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2912CD011F6A830700C6CBE3 /* Assets.xcassets */; };
2912CD1B1F6A830700C6CBE3 /* TrustUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2912CD1A1F6A830700C6CBE3 /* TrustUITests.swift */; };
@ -533,7 +532,6 @@
290B2B691F92C0440053C83E /* ConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigTests.swift; sourceTree = "<group>"; };
290B2B6B1F92C35B0053C83E /* RPCServerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RPCServerTests.swift; sourceTree = "<group>"; };
290B2B6D1F92C3980053C83E /* UserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = "<group>"; };
290B2B6F1F930AB90053C83E /* PushNotificationsRegistrar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushNotificationsRegistrar.swift; sourceTree = "<group>"; };
2912CCF51F6A830700C6CBE3 /* AlphaWallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AlphaWallet.app; sourceTree = BUILT_PRODUCTS_DIR; };
2912CCF81F6A830700C6CBE3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2912CD011F6A830700C6CBE3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@ -1542,7 +1540,6 @@
isa = PBXGroup;
children = (
29F1C85920036968003780D8 /* HelpUsCoordinator.swift */,
290B2B6F1F930AB90053C83E /* PushNotificationsRegistrar.swift */,
7721A6CF202EFD07004DB16C /* AddCustomNetworkCoordinator.swift */,
5E7C7B1FB2702A2A8A4EBD76 /* SettingsCoordinator.swift */,
5E7C7B8FD1E2BCC325DF4EE4 /* ServersCoordinator.swift */,
@ -3506,7 +3503,6 @@
293112101FC4ADCB00966EEA /* InCoordinatorViewModel.swift in Sources */,
293112351FC9A0D500966EEA /* CallRequest.swift in Sources */,
291F52A91F6B7BE100B369AB /* BlockNumber.swift in Sources */,
290B2B701F930AB90053C83E /* PushNotificationsRegistrar.swift in Sources */,
739533971FEFF5FD0084AFAB /* Currency.swift in Sources */,
298542F31FBD594D00CB5081 /* SettingsViewModel.swift in Sources */,
CCA4FE381FD428B300749AE4 /* JailbreakChecker.swift in Sources */,

@ -12,7 +12,6 @@ class AppCoordinator: NSObject, Coordinator {
controller.delegate = self
return controller
}()
let pushNotificationRegistrar = PushNotificationsRegistrar()
private let lock = Lock()
private var keystore: Keystore
private var appTracker = AppTracker()
@ -58,7 +57,6 @@ class AppCoordinator: NSObject, Coordinator {
} else {
resetToWelcomeScreen()
}
pushNotificationRegistrar.reRegister()
}
func showTransactions(for wallet: Wallet) {
@ -99,19 +97,11 @@ class AppCoordinator: NSObject, Coordinator {
@objc func reset() {
lock.deletePasscode()
pushNotificationRegistrar.unregister()
coordinators.removeAll()
navigationController.dismiss(animated: true, completion: nil)
resetToWelcomeScreen()
}
func didRegisterForRemoteNotificationsWithDeviceToken(deviceToken: Data) {
pushNotificationRegistrar.didRegister(
with: deviceToken,
addresses: keystore.wallets.map { $0.address }
)
}
func importPaidSignedOrder(signedOrder: SignedOrder, tokenObject: TokenObject, completion: @escaping (Bool) -> Void) {
let inCoordinatorInstance = coordinators.first {
$0 is InCoordinator
@ -167,11 +157,9 @@ extension AppCoordinator: InitialWalletCreationCoordinatorDelegate {
extension AppCoordinator: InCoordinatorDelegate {
func didCancel(in coordinator: InCoordinator) {
removeCoordinator(coordinator)
pushNotificationRegistrar.reRegister()
reset()
}
func didUpdateAccounts(in coordinator: InCoordinator) {
pushNotificationRegistrar.reRegister()
}
}

@ -29,9 +29,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
appCoordinator.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken: deviceToken)
}
func applicationWillResignActive(_ application: UIApplication) {
protectionCoordinator.applicationWillResignActive()
}

@ -1,21 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "settings_push_notifications.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

@ -56,7 +56,6 @@
"settings.biometricsEnabled.label.title" = "Passcode / %@";
"settings.error.failedToSendEmail" = "Failed to send email. Make sure you have Mail app installed.";
"settings.network.button.title" = "Network";
"settings.pushNotifications.button.title" = "Push Notifications";
"settings.language.button.title" = "Language";
"settings.language.useSystem.title" = "Use System Setting";
"settings.version.label.title" = "Version";

@ -63,7 +63,6 @@
"settings.biometricsEnabled.label.title" = "Código de acceso / %@";
"settings.error.failedToSendEmail" = "Error al enviar el correo electrónico Asegúrate de tener instalada la aplicación Mail.";
"settings.network.button.title" = "Red";
"settings.pushNotifications.button.title" = "Notificaciones Push";
"settings.language.button.title" = "Language";
"settings.language.useSystem.title" = "Use System Setting";
"settings.version.label.title" = "Versión";

@ -48,7 +48,6 @@
"settings.biometricsEnabled.label.title" = "密码 / %@";
"settings.error.failedToSendEmail" = "无法发送邮件。请确保你已经安装了邮件应用。";
"settings.network.button.title" = "网络";
"settings.pushNotifications.button.title" = "推送通知";
"settings.language.button.title" = "语言";
"settings.language.useSystem.title" = "使用系统设置";
"settings.version.label.title" = "版本";

@ -1,52 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import UserNotifications
import UIKit
import Moya
import TrustKeystore
class PushNotificationsRegistrar {
private let trustProvider = TrustProviderFactory.makeProvider()
let config = Config()
var isRegisteredForRemoteNotifications: Bool {
return UIApplication.shared.isRegisteredForRemoteNotifications
}
func reRegister() {
guard isRegisteredForRemoteNotifications else { return }
register()
}
func register() {
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound]) { _, _ in }
UIApplication.shared.registerForRemoteNotifications()
}
func unregister() {
let device = PushDevice(
deviceID: UIDevice.current.identifierForVendor!.uuidString,
token: "",
wallets: []
)
trustProvider.request(.unregister(device: device)) { _ in }
UIApplication.shared.unregisterForRemoteNotifications()
}
func didRegister(with deviceToken: Data, addresses: [Address]) {
let token = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}.joined()
let device = PushDevice(
deviceID: UIDevice.current.identifierForVendor!.uuidString,
token: token,
wallets: addresses.map { $0.description }
)
trustProvider.request(.register(device: device)) { _ in }
}
}

@ -21,7 +21,6 @@ class SettingsCoordinator: Coordinator {
let storage: TransactionsStorage
let balanceCoordinator: GetBalanceCoordinator
weak var delegate: SettingsCoordinatorDelegate?
let pushNotificationsRegistrar = PushNotificationsRegistrar()
var coordinators: [Coordinator] = []
lazy var rootViewController: SettingsViewController = {
@ -110,13 +109,6 @@ extension SettingsCoordinator: SettingsViewControllerDelegate {
showLocales()
case .RPCServer, .currency, .DAppsBrowser:
restart(for: session.account)
case .pushNotifications(let enabled):
switch enabled {
case true:
pushNotificationsRegistrar.register()
case false:
pushNotificationsRegistrar.unregister()
}
case .locale:
restart(for: session.account)
}

@ -12,6 +12,5 @@ enum AlphaWalletSettingsAction {
case servers
case currency
case DAppsBrowser
case pushNotifications(enabled: Bool)
case locale
}

@ -17,13 +17,6 @@ class SettingsViewController: FormViewController {
var isPasscodeEnabled: Bool {
return lock.isPasscodeSet()
}
static var isPushNotificationEnabled: Bool {
guard let settings = UIApplication.shared.currentUserNotificationSettings
else {
return false
}
return UIApplication.shared.isRegisteredForRemoteNotifications && !settings.types.isEmpty
}
lazy var viewModel: SettingsViewModel = {
return SettingsViewModel(isDebug: isDebug)
}()
@ -81,18 +74,6 @@ class SettingsViewController: FormViewController {
cell.imageView?.image = R.image.settings_lock()?.withRenderingMode(.alwaysTemplate)
}
<<< AlphaWalletSettingsSwitchRow {
$0.title = R.string.localizable.settingsPushNotificationsButtonTitle()
$0.value = SettingsViewController.isPushNotificationEnabled
}.onChange { [unowned self] row in
let enabled = row.value ?? false
self.run(action: .pushNotifications(enabled: enabled))
}.cellSetup { cell, _ in
cell.imageView?.tintColor = Colors.appBackground
cell.imageView?.image = R.image.settings_push_notifications()?.withRenderingMode(.alwaysTemplate)
}
<<< linkProvider(type: .twitter)
<<< linkProvider(type: .reddit)
<<< linkProvider(type: .facebook)

Loading…
Cancel
Save