Skip to content

Commit

Permalink
Merge branch 'release/3.19.2' of github.com:gnosis/safe-ios into rele…
Browse files Browse the repository at this point in the history
…ase/3.19.2
  • Loading branch information
MouazAlzahabi committed May 10, 2023
2 parents ed2ee5a + bb5432a commit eac2d50
Show file tree
Hide file tree
Showing 32 changed files with 224 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Multisig.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7175,7 +7175,7 @@
repositoryURL = "https://github.com/intercom/intercom-ios.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 10.3.5;
minimumVersion = 14.0.0;
};
};
D80B5A11276B5FAD00D6E024 /* XCRemoteSwiftPackageReference "SkeletonView" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
"repositoryURL": "https://github.com/intercom/intercom-ios.git",
"state": {
"branch": null,
"revision": "28c6d17951ed01cb7004cf37581684451a151fc1",
"version": "10.4.0"
"revision": "f994f1f203ae7479381642b6d1c58ffe419ee0ea",
"version": "14.1.0"
}
},
{
Expand Down
5 changes: 2 additions & 3 deletions Multisig/App/AppDelegate+Messaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
import UIKit
import UserNotifications
import Firebase
import Intercom

extension AppDelegate: UNUserNotificationCenterDelegate {

Expand All @@ -32,8 +31,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate {

Messaging.messaging().appDidReceiveMessage(userInfo)

if Intercom.isIntercomPushNotification(userInfo) {
App.shared.intercomConfig.pushNotificationUserInfo = userInfo
if IntercomConfig.isIntercomPushNotification(userInfo) {
IntercomConfig.pushNotificationUserInfo = userInfo
}

if SafeDeploymentNotificationController.isSafeCreatedNotification(userInfo) {
Expand Down
11 changes: 6 additions & 5 deletions Multisig/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import UIKit
import SwiftUI
import Firebase
import Intercom

class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
App.shared.firebaseConfig.setUp()
App.shared.intercomConfig.setUp()
IntercomConfig.setUp()

UIApplication.shared.registerForRemoteNotifications()

Expand Down Expand Up @@ -86,16 +85,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
LogService.shared.debug("PUSH: Received APNS token: \(deviceToken.toHexStringWithPrefix())")
Messaging.messaging().apnsToken = deviceToken
Intercom.setDeviceToken(deviceToken)
IntercomConfig.setDeviceToken(deviceToken) { error in
// this will fail before a Safe was added
}
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
LogService.shared.debug("PUSH: didReceiveRemoteNotification with userInfo: \(userInfo)")
Messaging.messaging().appDidReceiveMessage(userInfo)

if Intercom.isIntercomPushNotification(userInfo) {
if IntercomConfig.isIntercomPushNotification(userInfo) {
LogService.shared.debug("PUSH: didReceiveRemoteNotification Intercom push notification with userInfo: \(userInfo)")
App.shared.intercomConfig.pushNotificationUserInfo = userInfo
IntercomConfig.pushNotificationUserInfo = userInfo
}

completionHandler(.noData)
Expand Down
5 changes: 2 additions & 3 deletions Multisig/App/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
if presentedWindow === tabBarWindow {
privacyShieldWindow?.isHidden = false
}
App.shared.intercomConfig.hide()
IntercomConfig.hide()
}

func sceneDidEnterBackground(_ scene: UIScene) {
Expand Down Expand Up @@ -316,8 +316,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

func showMainContentWindow() {
showWindow(tabBarWindow)
App.shared.intercomConfig.appDidShowMainContent()

IntercomConfig.appDidShowMainContent()
}

func onTermsCompletion() {
Expand Down
2 changes: 0 additions & 2 deletions Multisig/Cross-layer/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,5 @@ class App {

let firebaseConfig = FirebaseConfig()

let intercomConfig = IntercomConfig()

private init() {}
}
24 changes: 13 additions & 11 deletions Multisig/Cross-layer/Configuration/Config.Example.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ WALLETCONNECT_BRIDGE_URL = https:/$()/safe-walletconnect.safe.global/
WALLETCONNECT_REGISTRY_URL = https:/$()/5afe.github.io/

// Help URLs
CONFLICT_URL = https:/$()/help.safe.global/en/articles/4730252-why-are-transactions-with-the-same-nonce-conflicting-with-each-other
FALLBACKHANDLER_URL = https:/$()/help.safe.global/en/articles/4738352-what-is-a-fallback-handler-and-how-does-it-relate-to-the-gnosis-safe
DELEGATE_KEY_URL = https:/$()/help.safe.global/en/articles/5809867-what-is-a-delegate-key
GUARD_URL = https:/$()/help.safe.global/en/articles/5324092-what-is-a-transaction-guard
PAY_FOR_CANCELLATION_URL = https:/$()/help.safe.global/en/articles/4738501-why-do-i-need-to-pay-for-cancelling-a-transaction
CONNECT_DAPP_ON_MOBILE_URL = https:/$()/help.safe.global/en/articles/5307197-how-to-connect-a-dapp-via-walletconnect-on-gnosis-safe-mobile
DESKTOP_PAIRING_URL = https:/$()/help.safe.global/en/articles/5584901-desktop-pairing
ADVANCED_TX_PARAMS_URL = https:/$()/help.safe.global/en/articles/4738445-advanced-transaction-parameters
CONFLICT_URL = https:/$()/help.safe.global/en/articles/40839-why-are-transactions-with-the-same-nonce-conflicting-with-each-other
FALLBACKHANDLER_URL = https:/$()/help.safe.global/en/articles/40838-what-is-a-fallback-handler-and-how-does-it-relate-to-safe
DELEGATE_KEY_URL = https:/$()/help.safe.global/en/articles/40799-what-is-a-delegate-key
GUARD_URL = https:/$()/help.safe.global/en/articles/40809-what-is-a-transaction-guard
PAY_FOR_CANCELLATION_URL = https:/$()/help.safe.global/en/articles/40836-why-do-i-need-to-pay-for-cancelling-a-transaction
CONNECT_DAPP_ON_MOBILE_URL = https:/$()/help.safe.global/en/articles/40810-connect-to-dapps-with-walletconnect-on-mobile
DESKTOP_PAIRING_URL = https:/$()/help.safe.global/en/articles/40801-connect-to-web-with-mobile-safe
ADVANCED_TX_PARAMS_URL = https:/$()/help.safe.global/en/articles/40837-advanced-transaction-parameters
LEDGER_PAIRING_URL = https:/$()/support.ledger.com/hc/en-us/articles/360019138694-Set-up-Bluetooth-connection
CREATE_SAFE_URL = https:/$()/help.safe.global/en/articles/3876461-create-a-safe
CONFIRMATIONS_URL = https:/$()/help.safe.global/en/articles/3952319-signature-policies
RELAYER_INFO_URL = https:/$()/help.safe.global/en/articles/7224713-what-is-gas-fee-sponsoring
CREATE_SAFE_URL = https:/$()/help.safe.global/en/articles/40792-how-to-create-a-safe-on-your-ios
CONFIRMATIONS_URL = https:/$()/help.safe.global/en/articles/40863-signature-policies
RELAYER_INFO_URL = https:/$()/help.safe.global/en/articles/59203-what-is-gas-fee-sponsoring
UNEXPECTED_DELEGATE_URL = https:/$()/help.safe.global/en/articles/40794-why-do-i-see-an-unexpected-delegate-call-warning-in-my-transaction
KEY_SECURITY_URL = https:/$()/help.safe.global/en/articles/40829-how-signer-keys-are-stored

// Legal URLs
TERMS_URL = https:/$()/app.safe.global/terms
Expand Down
6 changes: 6 additions & 0 deletions Multisig/Cross-layer/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ struct AppConfiguration {

@ConfigurationKey("RELAYER_INFO_URL")
var relayerInfoURL: URL

@ConfigurationKey("KEY_SECURITY_URL")
var keySecurityURL: URL

@ConfigurationKey("UNEXPECTED_DELEGATE_URL")
var unexpectedDelegateURL: URL
}

struct Legal {
Expand Down
46 changes: 32 additions & 14 deletions Multisig/Cross-layer/Configuration/IntercomConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,59 @@ import Intercom

class IntercomConfig {

var pushNotificationUserInfo: [AnyHashable : Any]?
static var pushNotificationUserInfo: [AnyHashable : Any]?

func setUp() {
static func setUp() {
Intercom.setApiKey(App.configuration.services.intercomApiKey, forAppId: App.configuration.services.intercomAppId)

#if DEBUG
Intercom.enableLogging()
#endif
Intercom.registerUnidentifiedUser()

disableChatOverlay()
Intercom.loginUnidentifiedUser { result in
switch result {
case .success:
LogService.shared.debug("Anonymous login to Intercm succeeded")
case .failure(let error):
App.shared.snackbar.show(message: "Anonymous login to Intercom failed: \(error)")
}
}
IntercomConfig.disableChatOverlay()
}

func disableChatOverlay() {
private static func disableChatOverlay() {
Intercom.setInAppMessagesVisible(false)
}

func startChat() {
Intercom.presentMessenger()
static func startChat() {
Intercom.present()
}

func hide() {
static func hide() {
Intercom.hide()
}

func appDidShowMainContent() {
static func appDidShowMainContent() {
// adding delay hack to handle the case when this shows right after app start - in that case we would see the
// black window background behind the intercom window. We give the app time to initialize.
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(250)) { [weak self] in
guard let self = self, let userInfo = self.pushNotificationUserInfo else {
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(250)) {
guard let userInfo = IntercomConfig.pushNotificationUserInfo else {
return
}
self.pushNotificationUserInfo = nil
IntercomConfig.pushNotificationUserInfo = nil
Intercom.handlePushNotification(userInfo)
self.startChat()
IntercomConfig.startChat()
}
}

static func unreadConversationCount() -> UInt {
Intercom.unreadConversationCount()
}

static func isIntercomPushNotification(_ userInfo: [AnyHashable : Any]) -> Bool {
Intercom.isIntercomPushNotification(userInfo)
}

static func setDeviceToken(_ deviceToken: Data, failure: ((Error?) -> Void)? = nil) {
Intercom.setDeviceToken(deviceToken, failure: failure)
}
}
9 changes: 8 additions & 1 deletion Multisig/Cross-layer/FirebaseRemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ class FirebaseRemoteConfig {
case deprecated
case safeClaimEnabled
case crashDebugEnabled
//FIXME Remove feature flag and flag handling after release
case intercomMigration
}

private var remoteConfig: RemoteConfig
private let defaultValues: [String : NSObject] = [Key.newestVersion.rawValue : "" as NSObject,
Key.deprecatedSoon.rawValue : "" as NSObject,
Key.deprecated.rawValue : "" as NSObject,
Key.safeClaimEnabled.rawValue : false as NSObject]
Key.safeClaimEnabled.rawValue : false as NSObject,
Key.intercomMigration.rawValue : false as NSObject] //FIXME Remove feature flag and flag handling after release
private init() {
remoteConfig = RemoteConfig.remoteConfig()
let settings = RemoteConfigSettings()
Expand All @@ -36,6 +39,10 @@ class FirebaseRemoteConfig {
fetchConfig()
}

func boolValue(key: Key) -> Bool? {
remoteConfig[key.rawValue].boolValue
}

func value(key: Key) -> String? {
remoteConfig[key.rawValue].stringValue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ class WebConnectionsViewController: UITableViewController, ExternalURLSource, We

override func viewDidLoad() {
super.viewDidLoad()

url = App.configuration.help.desktopPairingURL
//FIXME Remove feature flag and flag handling after release
url = URL(string: "https://help.safe.global/en/articles/5584901-desktop-pairing")!
if FirebaseRemoteConfig.shared.boolValue(key: .intercomMigration) ?? false {
url = App.configuration.help.desktopPairingURL
}

title = "Connect to Web"

Expand Down
8 changes: 8 additions & 0 deletions Multisig/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<string>$(RELAYER_INFO_URL)</string>
<key>DESKTOP_PAIRING_URL</key>
<string>$(DESKTOP_PAIRING_URL)</string>
<key>UNEXPECTED_DELEGATE_URL</key>
<string>$(UNEXPECTED_DELEGATE_URL)</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>KEY_SECURITY_URL</key>
<string>$(KEY_SECURITY_URL)</string>
<key>DISCORD_URL</key>
<string>$(DISCORD_URL)</string>
<key>FORUM_URL</key>
Expand All @@ -91,6 +97,8 @@
<string>$(INTERCOM_API_KEY)</string>
<key>INTERCOM_APP_ID</key>
<string>$(INTERCOM_APP_ID)</string>
<key>IntercomRegion</key>
<string>EU</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>IntercomAutoIntegratePushNotifications</key>
Expand Down
2 changes: 0 additions & 2 deletions Multisig/Multisig_DEV.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:staging.5afe.dev</string>
<string>applinks:*.staging.5afe.dev</string>
<string>applinks:safe-web-core.staging.5afe.dev</string>
</array>
<key>com.apple.security.application-groups</key>
Expand Down
2 changes: 0 additions & 2 deletions Multisig/Multisig_PROD.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:safe.global</string>
<string>applinks:*.safe.global</string>
<string>applinks:app.safe.global</string>
</array>
<key>com.apple.security.application-groups</key>
Expand Down
2 changes: 0 additions & 2 deletions Multisig/Multisig_STAGING.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:staging.5afe.dev</string>
<string>applinks:*.staging.5afe.dev</string>
<string>applinks:safe-web-core.staging.5afe.dev</string>
</array>
<key>com.apple.security.application-groups</key>
Expand Down
3 changes: 1 addition & 2 deletions Multisig/UI/App/MainTabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import UIKit
import Intercom
import WhatsNewKit

class MainTabBarViewController: UITabBarController {
Expand Down Expand Up @@ -529,7 +528,7 @@ class SettingsUINavigationController: UINavigationController {
}

@objc func showBadge() {
let count = Intercom.unreadConversationCount()
let count = IntercomConfig.unreadConversationCount()
if count > 0 {
tabBarItem.badgeValue = ""
tabBarItem.badgeColor = UIColor.warning
Expand Down
Loading

0 comments on commit eac2d50

Please sign in to comment.