From 2175b7206f103bddcd2c6928ba33b4c65b993810 Mon Sep 17 00:00:00 2001 From: Andrey Scherbovich Date: Thu, 26 Nov 2020 15:03:13 +0100 Subject: [PATCH] gh-716 make adjustments --- .../RegisterNotificationTokenRequest.swift | 4 ++-- Multisig/Logic/Models/Signer.swift | 2 +- Multisig/UI/App/RemoteNotificationHandler.swift | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Multisig/Data/Services/Notification Service/RegisterNotificationTokenRequest.swift b/Multisig/Data/Services/Notification Service/RegisterNotificationTokenRequest.swift index fcc8e8450..779085609 100644 --- a/Multisig/Data/Services/Notification Service/RegisterNotificationTokenRequest.swift +++ b/Multisig/Data/Services/Notification Service/RegisterNotificationTokenRequest.swift @@ -44,7 +44,7 @@ struct RegisterNotificationTokenRequest: JSONRequest { let string = [ "gnosis-safe", self.uuid, - self.safes.reduce("") { $0 + $1 }, + self.safes.joined(), self.cloudMessagingToken, self.bundle, self.version, @@ -52,7 +52,7 @@ struct RegisterNotificationTokenRequest: JSONRequest { self.buildNumber, self.timestamp ] - .reduce("") { $0 + $1 } + .joined() if let signature = try? Signer.sign(string).value { self.signatures = [signature] diff --git a/Multisig/Logic/Models/Signer.swift b/Multisig/Logic/Models/Signer.swift index 287bdd53a..4bcb4a153 100644 --- a/Multisig/Logic/Models/Signer.swift +++ b/Multisig/Logic/Models/Signer.swift @@ -22,7 +22,7 @@ class Signer { /// - Throws: errors during sisgning process /// - Returns: Signature object containing hex(r) hex(s) hex(v + 27) as one strig of secp256k1 signature static func sign(_ string: String) throws -> Signature { - let hash = EthHasher.hash(string.data(using: .ascii)!) + let hash = EthHasher.hash(string.data(using: .utf8)!) return try sign(hash: hash) } diff --git a/Multisig/UI/App/RemoteNotificationHandler.swift b/Multisig/UI/App/RemoteNotificationHandler.swift index 684ba809b..adb7d7fa5 100644 --- a/Multisig/UI/App/RemoteNotificationHandler.swift +++ b/Multisig/UI/App/RemoteNotificationHandler.swift @@ -66,7 +66,9 @@ class RemoteNotificationHandler { func safeAdded(address: Address) { logDebug("Safe added: \(address)") - if authorizationStatus != nil { + if authorizationStatus == nil { + requestUserPermissionAndRegister() + } else { register(addresses: [address]) } }