From 437c35637fcec041378d2a185f92ca747841d167 Mon Sep 17 00:00:00 2001 From: iSecNew10 Date: Thu, 6 Apr 2023 08:24:18 +0200 Subject: [PATCH] Add ref code for appdb links --- appdb/Startup/Global.swift | 2 ++ appdb/Tabs/Featured/Details/Details.swift | 2 +- appdb/Tabs/Settings/Credits/Credits.swift | 2 +- appdb/Tabs/Settings/Device Link/BulletinDataSource.swift | 2 +- .../Device Link/Bulletins/EnterLinkCodeBulletinPage.swift | 2 +- appdb/Tabs/Settings/News/News+Detail.swift | 6 +++--- appdb/Tabs/Settings/Settings+Sections.swift | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/appdb/Startup/Global.swift b/appdb/Startup/Global.swift index 0db9d42c..91cff0a5 100644 --- a/appdb/Startup/Global.swift +++ b/appdb/Startup/Global.swift @@ -32,6 +32,8 @@ enum Global { static let adsTestMode: Bool = !DEBUG static let mainSite: String = "https://appdb.to/" + static let refCode: String = "fc2b87d32abe29180b9da168d5a599e8" + static let githubSite: String = "https://github.com/n3d1117/appdb" static let donateSite: String = "https://www.buymeacoffee.com/ne_do" // static let email: String = "appdb.ned@gmail.com" diff --git a/appdb/Tabs/Featured/Details/Details.swift b/appdb/Tabs/Featured/Details/Details.swift index 3602bb80..4be70cfd 100644 --- a/appdb/Tabs/Featured/Details/Details.swift +++ b/appdb/Tabs/Featured/Details/Details.swift @@ -87,7 +87,7 @@ class Details: LoadingTableView { // MARK: - Share @objc func share(sender: UIBarButtonItem) { - let urlString = "\(Global.mainSite)app/\(contentType.rawValue)/\(content.itemId)" + let urlString = "\(Global.mainSite)app/\(contentType.rawValue)/\(content.itemId)?ref=\(Global.refCode)" guard let url = URL(string: urlString) else { return } let activity = UIActivityViewController(activityItems: [url], applicationActivities: [SafariActivity()]) if #available(iOS 11.0, *) {} else { diff --git a/appdb/Tabs/Settings/Credits/Credits.swift b/appdb/Tabs/Settings/Credits/Credits.swift index 231641ea..d9756354 100644 --- a/appdb/Tabs/Settings/Credits/Credits.swift +++ b/appdb/Tabs/Settings/Credits/Credits.swift @@ -38,7 +38,7 @@ class Credits: TableViewController { Credit(name: "View project on GitHub".localized(), imageName: "github", type: .developer, handle: .website(site: Global.githubSite)), Credit(name: "Buy me a coffee".localized(), imageName: "bmac", type: .developer, handle: .website(site: Global.donateSite)), - Credit(name: "appdb team", imageName: "appdb", type: .specialThanks, handle: .website(site: Global.mainSite)), + Credit(name: "appdb team", imageName: "appdb", type: .specialThanks, handle: .website(site: Global.mainSite + "?ref=" + Global.refCode)), Credit(name: "Alessandro Chiarlitti (aesign)", detail: "Icon and banner designer".localized(), imageName: "aesign", type: .specialThanks, handle: .website(site: "https://aesign.me")), Credit(name: "TNT 🇪🇸", imageName: "tnt", type: .translations, handle: .none), diff --git a/appdb/Tabs/Settings/Device Link/BulletinDataSource.swift b/appdb/Tabs/Settings/Device Link/BulletinDataSource.swift index 86f1be86..31b185a6 100644 --- a/appdb/Tabs/Settings/Device Link/BulletinDataSource.swift +++ b/appdb/Tabs/Settings/Device Link/BulletinDataSource.swift @@ -23,7 +23,7 @@ enum DeviceLinkIntroBulletins { if page.deviceIsNotYetLinked { // If device is not yet linked to appdb there's not much I can do: just redirect // user to the web page where he can link it (APIs to link manually no longer work) - let linkPageUrlString = "\(Global.mainSite)link" + let linkPageUrlString = "\(Global.mainSite)link?ref=\(Global.refCode)" NotificationCenter.default.post(name: .OpenSafari, object: self, userInfo: ["URLString": "\(linkPageUrlString)"]) } else { item.manager?.displayActivityIndicator(color: Themes.isNight ? .white : .black) diff --git a/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift b/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift index e50f0ddc..85cf64b0 100644 --- a/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift +++ b/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift @@ -49,7 +49,7 @@ class EnterLinkCodeBulletinPage: BLTNPageItem { @objc private func linkButtonTapped(sender: UIButton) { guard let url = sender.titleLabel?.text else { return } - NotificationCenter.default.post(name: .OpenSafari, object: self, userInfo: ["URLString": "\(url)"]) + NotificationCenter.default.post(name: .OpenSafari, object: self, userInfo: ["URLString": "\(url)?ref=\(Global.refCode)"]) } override func actionButtonTapped(sender: UIButton) { diff --git a/appdb/Tabs/Settings/News/News+Detail.swift b/appdb/Tabs/Settings/News/News+Detail.swift index 94e6d45f..697588e7 100644 --- a/appdb/Tabs/Settings/News/News+Detail.swift +++ b/appdb/Tabs/Settings/News/News+Detail.swift @@ -71,7 +71,7 @@ class NewsDetail: LoadingTableView { @objc private func share(sender: UIBarButtonItem) { let text = item.title - let urlString = "\(Global.mainSite)news/\(item.id)" + let urlString = "\(Global.mainSite)news/\(item.id)?ref=\(Global.refCode)" guard let url = URL(string: urlString) else { return } let activity = UIActivityViewController(activityItems: [text, url], applicationActivities: [SafariActivity()]) if #available(iOS 11.0, *) {} else { @@ -199,7 +199,7 @@ extension AttributedLabel { switch detection.type { case .link(let url): var partialUrl = url.absoluteString.replacingOccurrences(of: "&", with: "&") - if !partialUrl.hasPrefix("http") { partialUrl = "http://" + partialUrl } + if !partialUrl.hasPrefix("http") { partialUrl = "http://" + partialUrl + "&ref=\(Global.refCode)" } guard let fullUrl = URL(string: partialUrl) else { return } UIApplication.shared.open(fullUrl) case .tag(let tag): @@ -209,7 +209,7 @@ extension AttributedLabel { UIApplication.shared.open(url) } else { while href.hasPrefix("/") { href = String(href.dropFirst()) } - let urlString: String = "\(Global.mainSite)\(href)".replacingOccurrences(of: "&", with: "&") + let urlString: String = "\(Global.mainSite)\(href)&ref=\(Global.refCode)".replacingOccurrences(of: "&", with: "&") guard let url = URL(string: urlString) else { return } UIApplication.shared.open(url) } diff --git a/appdb/Tabs/Settings/Settings+Sections.swift b/appdb/Tabs/Settings/Settings+Sections.swift index 019f2bc8..6e4ba213 100644 --- a/appdb/Tabs/Settings/Settings+Sections.swift +++ b/appdb/Tabs/Settings/Settings+Sections.swift @@ -27,7 +27,7 @@ extension Settings { } var proSite: String { - Global.mainSite + "my/buy?lt=" + Preferences.linkToken + Global.mainSite + "my/buy?ref=" + Global.refCode + "<=" + Preferences.linkToken } var themeSection: [Static.Section] {