diff --git a/Podfile b/Podfile index 85ce140..b64bc54 100644 --- a/Podfile +++ b/Podfile @@ -9,5 +9,6 @@ target 'blista' do pod 'Firebase/Core' pod 'Firebase/Messaging' +pod 'SwiftyJSON', '~> 4.0' end diff --git a/Podfile.lock b/Podfile.lock index 90d6581..eec111f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -77,10 +77,12 @@ PODS: - nanopb/encode (1.30906.0) - PromisesObjC (1.2.10) - Protobuf (3.13.0) + - SwiftyJSON (4.3.0) DEPENDENCIES: - Firebase/Core - Firebase/Messaging + - SwiftyJSON (~> 4.0) SPEC REPOS: trunk: @@ -97,6 +99,7 @@ SPEC REPOS: - nanopb - PromisesObjC - Protobuf + - SwiftyJSON SPEC CHECKSUMS: Firebase: c23a36d9e4cdf7877dfcba8dd0c58add66358999 @@ -112,7 +115,8 @@ SPEC CHECKSUMS: nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc PromisesObjC: b14b1c6b68e306650688599de8a45e49fae81151 Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748 + SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08 -PODFILE CHECKSUM: 520344186de1f29c76e02112d62a271448eeb812 +PODFILE CHECKSUM: c7a300f02ff7a4a60adc671fd33d1293385e5d7e COCOAPODS: 1.10.1 diff --git a/blista.xcodeproj/project.pbxproj b/blista.xcodeproj/project.pbxproj index 95c8358..2d4ed4d 100644 --- a/blista.xcodeproj/project.pbxproj +++ b/blista.xcodeproj/project.pbxproj @@ -385,6 +385,7 @@ "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework", "${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework", "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework", + "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework", "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -392,6 +393,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", ); runOnlyForDeploymentPostprocessing = 0; @@ -589,7 +591,7 @@ INFOPLIST_FILE = blista/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.20.1; + MARKETING_VERSION = 1.20.2; PRODUCT_BUNDLE_IDENTIFIER = de.zitrotec.blista; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -619,7 +621,7 @@ INFOPLIST_FILE = blista/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.20.1; + MARKETING_VERSION = 1.20.2; PRODUCT_BUNDLE_IDENTIFIER = de.zitrotec.blista; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/blista.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/xcschememanagement.plist b/blista.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/xcschememanagement.plist index dfb95cc..c889504 100644 --- a/blista.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/blista.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ blista.xcscheme_^#shared#^_ orderHint - 14 + 15 diff --git a/blista/FirstViewController.swift b/blista/FirstViewController.swift index 5d037c1..e982043 100644 --- a/blista/FirstViewController.swift +++ b/blista/FirstViewController.swift @@ -8,6 +8,7 @@ import UIKit import Crashlytics +import SwiftyJSON class FirstViewController: UIViewController, UIWebViewDelegate { @@ -25,12 +26,236 @@ class FirstViewController: UIViewController, UIWebViewDelegate { return } } + + func activateMe() { + + let alert = UIAlertController(title: "Bitte denk über eine Spende nach", message: "Die Entwicklung der blistar-App kostet viel Zeit und Geld. Spende für die blistar-App und sichere die Weiterentwicklung der App oder warte 60 Sekunden.", preferredStyle: .alert) + + alert.addAction(UIAlertAction(title: "Spenden", style: .default, handler: { action in + let url = URL(string:"https://zitrotec.de/it-service/referenzen/blista/blistar-app-support-plan") + + let reachability = Reachability()! + + switch reachability.connection { + case .wifi: + + if #available(iOS 10.0, *) { + UIApplication.shared.open(url!, options: [:], completionHandler: nil) + } else { + UIApplication.shared.openURL(url!) + } + self.present(alert, animated: true) + + case .cellular: + + if #available(iOS 10.0, *) { + UIApplication.shared.open(url!, options: [:], completionHandler: nil) + } else { + UIApplication.shared.openURL(url!) + } + self.present(alert, animated: true) + + case .none: + let alert3 = UIAlertView() + alert3.title = "Du bist Offline" + alert3.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen." + alert3.addButton(withTitle: "OK") + alert3.show() + self.present(alert, animated: true) + } + })) + + alert.addAction(UIAlertAction(title: "Spendenschlüssel eingeben", style: .default, handler: { action in + + let alert2 = UIAlertController(title: "Spendenschlüssel", message: nil, preferredStyle: .alert) + alert2.addAction(UIAlertAction(title: "Abbrechen", style: .cancel, handler: { action in + + self.present(alert, animated: true) + + })) + alert2.addTextField(configurationHandler: { textField in + textField.placeholder = "Gib deinen Spendenschlüssel ein" + }) + + alert2.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in + + let license = alert2.textFields![0] + + if license.text != "" { + let licenseString = license.text! + print(licenseString) + UIApplication.shared.isNetworkActivityIndicatorVisible = true + + guard let url = URL(string: "https://zitrotec.de/it-service/wp-admin/admin-ajax.php?action=license_key_activate&store_code=F3Up0N7tI87JWEp&sku=blistar-app-subscription-m&license_key=\(licenseString)") else {return} + let task = URLSession.shared.dataTask(with: url) { (data, response, error) in + guard let dataResponse = data, + error == nil else { + print(error?.localizedDescription ?? "Response Error") + UIApplication.shared.isNetworkActivityIndicatorVisible = false + + DispatchQueue.main.async { + let alert5 = UIAlertController(title: "Fehler: " + (error?.localizedDescription ?? "Response Error"), message: "Hilfe zu diesem Fehler findest du auf der Spendenseite.", preferredStyle: UIAlertControllerStyle.alert) + + let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in + self.present(alert, animated: true) + }) + + alert5.addAction(action) + self.present(alert5, animated: true, completion: nil) + + } + + return } + let json = try? JSON(data: dataResponse) + let status = json?["status"].stringValue + print(status ?? "null") + let error = json?["errors"]["license_key"][0].stringValue + print(error ?? "null") + + if (status != "200") { + + UIApplication.shared.isNetworkActivityIndicatorVisible = false + + DispatchQueue.main.async { + let alert4 = UIAlertController(title: "Fehler: " + (error ?? "null"), message: "Hilfe zu diesem Fehler findest du auf der Spendenseite.", preferredStyle: UIAlertControllerStyle.alert) + + let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in + self.present(alert, animated: true) + }) + + alert4.addAction(action) + self.present(alert4, animated: true, completion: nil) + + } + + } + + else { + + let message = json?["message"].stringValue + + let activation_id = json?["data"]["activation_id"].stringValue + + let expire_date = json?["data"]["expire_date"].stringValue + + let the_key = json?["data"]["the_key"].stringValue + + let url = json?["data"]["url"].stringValue + + let has_expired = json?["data"]["has_expired"].stringValue + + let status = json?["data"]["status"].stringValue + + let ctoken = json?["data"]["ctoken"].stringValue + + let name = json?["data"]["name"].stringValue + + print("Message:") + print(message ?? "null"); + print("activation_id:") + print(activation_id ?? "null"); + print("expire_date:") + print(expire_date ?? "null"); + print("the_key:") + print(the_key ?? "null"); + print("url:") + print(url ?? "null"); + print("has_expired:") + print(has_expired ?? "null"); + print("status:") + print(status ?? "null"); + print("ctoken:") + print(ctoken ?? "null"); + print("name:") + print(name ?? "null"); + + let defaults = UserDefaults.standard + + defaults.set(activation_id, forKey: "activation_id") + defaults.set(expire_date, forKey: "expire_date") + defaults.set(the_key, forKey: "the_key") + defaults.set(url, forKey: "url") + defaults.set(status, forKey: "status") + defaults.set(has_expired, forKey: "has_expired") + defaults.set(ctoken, forKey: "ctoken") + defaults.set(name, forKey: "name") + defaults.set(true, forKey: "active") + + let UserInfo1 = "Abo: \n" + (name ?? "null") + let UserInfo2 = "\n Ablaufdatum: \n" + (expire_date ?? "null") + let UserInfo3 = "\n Aktivierungs-ID: \n" + (activation_id ?? "null") + let UserInfo = UserInfo1 + UserInfo2 + UserInfo3 + + UIApplication.shared.isNetworkActivityIndicatorVisible = false + + + DispatchQueue.main.async { + let alert7 = UIAlertController(title: "Erfolg: " + (message ?? "null"), message: "Vielen Dank für deine Unterstützung, die 60 Sek. Wartezeit entfällt nun. \n Details: \n" + (UserInfo ), preferredStyle: UIAlertControllerStyle.alert) + + let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in + // Spark! + }) + + alert7.addAction(action) + self.present(alert7, animated: true, completion: nil) + + } + + } + + } + task.resume() + + + } else { + + self.present(alert2, animated: true) + + } + + })) + + self.present(alert2, animated: true) + + })) + + self.present(alert, animated: true) + } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. + let defaults = UserDefaults.standard + + let activation_id = defaults.string(forKey: "activation_id") + let the_key = defaults.string(forKey: "the_key") + let url = defaults.string(forKey: "url") + let status = defaults.string(forKey: "status") + let has_expired = defaults.bool(forKey: "has_expired") + let ctoken = defaults.string(forKey: "ctoken") + let name = defaults.string(forKey: "name") + let active = defaults.bool(forKey: "active") + + + let launchedBefore = defaults.bool(forKey: "launchedBefore") + if launchedBefore + { + print("Not first launch.") + if !active { + activateMe() + DispatchQueue.main.asyncAfter(deadline: .now() + 60.0) { + self.dismiss(animated: true, completion: nil) + } + } + } + else + { + print("First launch") + defaults.set(true, forKey: "launchedBefore") + } + segmentedControl.sendActions(for: UIControlEvents.valueChanged) } diff --git a/blista/SixteenViewController.swift b/blista/SixteenViewController.swift index 801f0f9..daf6fe2 100644 --- a/blista/SixteenViewController.swift +++ b/blista/SixteenViewController.swift @@ -106,34 +106,95 @@ class SixteenViewController: UIViewController, UIWebViewDelegate { @objc func myRightSideBarButtonItemTapped(_ sender:UIBarButtonItem!) { - let url = URL(string:"https://zitrotec.de/it-service/referenzen/blista/spenden") - - let reachability = Reachability()! - switch reachability.connection { - case .wifi: - - if #available(iOS 10.0, *) { - UIApplication.shared.open(url!, options: [:], completionHandler: nil) - } else { - UIApplication.shared.openURL(url!) - } + let defaults = UserDefaults.standard + + let activation_id = defaults.string(forKey: "activation_id") + let the_key = defaults.string(forKey: "the_key") + let expire_date = defaults.string(forKey: "expire_date") + let has_expired = defaults.bool(forKey: "has_expired") + let name = defaults.string(forKey: "name") + let active = defaults.bool(forKey: "active") - case .cellular: + if active { + let UserInfo1 = "Abo: \n" + (name ?? "null") + let UserInfo2 = "\n Ablaufdatum: \n" + (expire_date ?? "null") + let UserInfo3 = "\n Aktivierungs-ID: \n" + (activation_id ?? "null") + let UserInfo = UserInfo1 + UserInfo2 + UserInfo3 + + let alert2 = UIAlertController(title: "Vielen Dank für deinen Support 💚", message: "Toll das du mithilfst, die blistar-App auch in Zukunft kostenlos anbieten zu können. \n Details: \n" + (UserInfo ), preferredStyle: UIAlertControllerStyle.alert) + + let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in + // Spark! + }) + + let action2 = UIAlertAction(title: "Abo verwalten", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in + let url2 = URL(string:"https://zitrotec.de/it-service/mein-konto/view-license-key?key=\(the_key ?? "null")") + + let reachability = Reachability()! + + switch reachability.connection { + case .wifi: + + if #available(iOS 10.0, *) { + UIApplication.shared.open(url2!, options: [:], completionHandler: nil) + } else { + UIApplication.shared.openURL(url2!) + } + + case .cellular: + + if #available(iOS 10.0, *) { + UIApplication.shared.open(url2!, options: [:], completionHandler: nil) + } else { + UIApplication.shared.openURL(url2!) + } + + case .none: + let alert = UIAlertView() + alert.title = "Du bist Offline" + alert.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen." + alert.addButton(withTitle: "OK") + alert.show() + } + }) + + alert2.addAction(action) + alert2.addAction(action2) + self.present(alert2, animated: true, completion: nil) + + } else { + + let url = URL(string:"https://zitrotec.de/it-service/referenzen/blista/spenden") - if #available(iOS 10.0, *) { - UIApplication.shared.open(url!, options: [:], completionHandler: nil) - } else { - UIApplication.shared.openURL(url!) - } + let reachability = Reachability()! + + switch reachability.connection { + case .wifi: + + if #available(iOS 10.0, *) { + UIApplication.shared.open(url!, options: [:], completionHandler: nil) + } else { + UIApplication.shared.openURL(url!) + } + + case .cellular: + + if #available(iOS 10.0, *) { + UIApplication.shared.open(url!, options: [:], completionHandler: nil) + } else { + UIApplication.shared.openURL(url!) + } + + case .none: + let alert = UIAlertView() + alert.title = "Du bist Offline" + alert.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen." + alert.addButton(withTitle: "OK") + alert.show() + } + } - case .none: - let alert = UIAlertView() - alert.title = "Du bist Offline" - alert.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen." - alert.addButton(withTitle: "OK") - alert.show() - } } override func didReceiveMemoryWarning() { diff --git a/license.txt b/license.txt index 5793a4b..89f4b55 100644 --- a/license.txt +++ b/license.txt @@ -20,12 +20,26 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -QRCodeReader.swift: +SwiftyJSON: -Copyright (c) 2014-present - Yannick Loriot +The MIT License (MIT) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Copyright (c) 2017 Ruoyu Fu -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.